feat(db): add users/currency/bans/settings read repositories
This commit is contained in:
1 parent
3e3776b477
commit
d04ed42586
7 files changed
+76
No files matched your search
@@ -0,0 +1,16 @@
|
||||
import { eq } from "drizzle-orm";
|
||||
import type { Database } from "../client.js";
|
||||
import { usersCurrency } from "../schema/users-currency.js";
|
||||
|
||||
export function makeCurrencyRepo(db: Database) {
|
||||
return {
|
||||
// Returns a map of currency type -> amount for one user.
|
||||
forUser: async (userId: number): Promise<Map<number, number>> => {
|
||||
const rows = await db
|
||||
.select()
|
||||
.from(usersCurrency)
|
||||
.where(eq(usersCurrency.userId, userId));
|
||||
return new Map(rows.map((r) => [r.type, r.amount]));
|
||||
},
|
||||
};
|
||||
}
|
||||
Reference in new issue
Block a user