MCPcopy Create free account
hub / github.com/WebDevSimplified/course-platform / insertUser

Function insertUser

src/features/users/db/users.ts:6–20  ·  view source on GitHub ↗
(data: typeof UserTable.$inferInsert)

Source from the content-addressed store, hash-verified

4import { revalidateUserCache } from "./cache"
5
6export 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
22export async function updateUser(
23 { clerkUserId }: { clerkUserId: string },

Callers 2

GETFunction · 0.90
POSTFunction · 0.90

Calls 1

revalidateUserCacheFunction · 0.90

Tested by

no test coverage detected