This commit is contained in:
2024-09-02 16:58:23 +02:00
parent c77503ed45
commit 1b0dc0f27d
52 changed files with 817 additions and 1379 deletions

View File

@@ -10,3 +10,5 @@ export function useDrizzle() {
const config = useRuntimeConfig()
return drizzle(postgres(config.postgres.url, { prepare: false, max: 50 }), { schema })
}
export type UserInsert = typeof schema.users.$inferInsert

View File

@@ -45,14 +45,14 @@ export async function createUser(user: UserInsert) {
}
export async function updateUser(userId: number, user: Partial<UserInsert>) {
return useDrizzle()
await useDrizzle()
.update(tables.users)
.set(user)
.where(eq(tables.users.id, userId))
}
export async function deleteProfilePicture(avatar: string) {
if (avatar.startsWith('profile-pictures/')) {
await hubBlob().delete(avatar)
if (avatar.startsWith('avatars/')) {
await hubBlob().del(avatar)
}
}