mirror of
https://github.com/hex248/sprint.git
synced 2026-02-08 02:33:01 +00:00
added avatarURL to user create + update functions
This commit is contained in:
@@ -2,8 +2,8 @@ import { User, type UserRecord } from "@issue/shared";
|
|||||||
import { eq } from "drizzle-orm";
|
import { eq } from "drizzle-orm";
|
||||||
import { db } from "../client";
|
import { db } from "../client";
|
||||||
|
|
||||||
export async function createUser(name: string, username: string, passwordHash: string) {
|
export async function createUser(name: string, username: string, passwordHash: string, avatarURL?: string) {
|
||||||
const [user] = await db.insert(User).values({ name, username, passwordHash }).returning();
|
const [user] = await db.insert(User).values({ name, username, passwordHash, avatarURL }).returning();
|
||||||
return user;
|
return user;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -19,7 +19,11 @@ export async function getUserByUsername(username: string) {
|
|||||||
|
|
||||||
export async function updateById(
|
export async function updateById(
|
||||||
id: number,
|
id: number,
|
||||||
updates: { name?: string; passwordHash?: string; serverURL?: string },
|
updates: {
|
||||||
|
name?: string;
|
||||||
|
passwordHash?: string;
|
||||||
|
avatarURL?: string;
|
||||||
|
},
|
||||||
): Promise<UserRecord | undefined> {
|
): Promise<UserRecord | undefined> {
|
||||||
const [user] = await db.update(User).set(updates).where(eq(User.id, id)).returning();
|
const [user] = await db.update(User).set(updates).where(eq(User.id, id)).returning();
|
||||||
return user;
|
return user;
|
||||||
|
|||||||
Reference in New Issue
Block a user