feat(db): add users/currency/bans/settings read repositories
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
import { eq } from "drizzle-orm";
|
||||
import type { Database } from "../client.js";
|
||||
import { users } from "../schema/users.js";
|
||||
|
||||
export function makeUsersRepo(db: Database) {
|
||||
return {
|
||||
findById: async (id: number) => {
|
||||
const rows = await db.select().from(users).where(eq(users.id, id)).limit(1);
|
||||
return rows[0] ?? null;
|
||||
},
|
||||
findByUsername: async (username: string) => {
|
||||
const rows = await db
|
||||
.select()
|
||||
.from(users)
|
||||
.where(eq(users.username, username))
|
||||
.limit(1);
|
||||
return rows[0] ?? null;
|
||||
},
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user