minor fixes, add superloot cheer

This commit is contained in:
2025-10-11 18:59:02 +02:00
parent e46cec80ed
commit c9fb09e36c
15 changed files with 119 additions and 37 deletions

View File

@@ -2,7 +2,7 @@ import db from "db/connection";
import { timeouts, users } from "db/schema";
import { itemarray, type inventory } from "items";
import type User from "user";
import { count, desc, eq, inArray, sql, ne, between, and, SQL } from "drizzle-orm";
import { count, desc, eq, inArray, sql, ne, between, and, SQL, type InferInsertModel, type InferSelectModel } from "drizzle-orm";
/** Use this function to both ensure existance and to retreive data */
export async function getUserRecord(user: User) {
@@ -32,11 +32,9 @@ async function createUserRecord(user: User) {
});
};
export type balanceUpdate = { balance: number; };
export type inventoryUpdate = { inventory: inventory; };
type updateUser = balanceUpdate | inventoryUpdate;
export type UserRecord = InferSelectModel<typeof users>;
export async function updateUserRecord(user: User, newData: updateUser) {
export async function updateUserRecord(user: User, newData: UserRecord) {
await db.update(users).set(newData).where(eq(users.id, parseInt(user.id)));
return true;
};