(data: typeof UserTable.$inferInsert)
| 4 | import { revalidateUserCache } from "./cache" |
| 5 | |
| 6 | export async function insertUser(data: typeof UserTable.$inferInsert) { |
| 7 | const [newUser] = await db |
| 8 | .insert(UserTable) |
| 9 | .values(data) |
| 10 | .returning() |
| 11 | .onConflictDoUpdate({ |
| 12 | target: [UserTable.clerkUserId], |
| 13 | set: data, |
| 14 | }) |
| 15 | |
| 16 | if (newUser == null) throw new Error("Failed to create user") |
| 17 | revalidateUserCache(newUser.id) |
| 18 | |
| 19 | return newUser |
| 20 | } |
| 21 | |
| 22 | export async function updateUser( |
| 23 | { clerkUserId }: { clerkUserId: string }, |
no test coverage detected