update user backend + frontend server function

This commit is contained in:
Oliver Bryan
2025-12-31 19:09:24 +00:00
parent 435540f158
commit c274ea9036
7 changed files with 99 additions and 11 deletions

View File

@@ -1,4 +1,4 @@
import { User } from "@issue/shared";
import { User, type UserRecord } from "@issue/shared";
import { eq } from "drizzle-orm";
import { db } from "../client";
@@ -16,3 +16,11 @@ export async function getUserByUsername(username: string) {
const [user] = await db.select().from(User).where(eq(User.username, username));
return user;
}
export async function updateById(
id: number,
updates: { name?: string; passwordHash?: string; serverURL?: string },
): Promise<UserRecord | undefined> {
const [user] = await db.update(User).set(updates).where(eq(User.id, id)).returning();
return user;
}