All files / src/features/authentication user.repository.server.ts

100% Statements 3/3
100% Branches 0/0
100% Functions 3/3
100% Lines 3/3

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27                50x   2x             5x                  
// The account's own details that the app changes itself; Better Auth owns
// the rest of the user table (openspec: authentication).
import { eq } from 'drizzle-orm'
import type { Locale } from '#/paraglide/runtime.js'
import { user } from '#/server/db/schema'
import type { Db } from '#/server/platform/db.server'
 
export function userRepository(db: Db) {
  return {
    async setName(userId: string, name: string, now: Date): Promise<void> {
      await db
        .update(user)
        .set({ name, updatedAt: now })
        .where(eq(user.id, userId))
    },
 
    async setLocale(userId: string, locale: Locale, now: Date): Promise<void> {
      await db
        .update(user)
        .set({ locale, updatedAt: now })
        .where(eq(user.id, userId))
    },
  }
}
 
export type UserRepository = ReturnType<typeof userRepository>