// users.ts
import { LIMIT } from "./usage"
export const createUser = mutation({
...
await ctx.db.insert("usage", {
userId,
used: 0,
limit: LIMIT,
})
...
const addUser = customCtx(async (ctx: QueryCtx) => {
const userId = await getUserIdByTokenIdentifier(ctx)
if (!userId) {
throw new ConvexError("User ID not found")
}
return { userId }
})
export const queryWithUser = customQuery(query, addUser)
// users.ts
import { LIMIT } from "./usage"
export const createUser = mutation({
...
await ctx.db.insert("usage", {
userId,
used: 0,
limit: LIMIT,
})
...
const addUser = customCtx(async (ctx: QueryCtx) => {
const userId = await getUserIdByTokenIdentifier(ctx)
if (!userId) {
throw new ConvexError("User ID not found")
}
return { userId }
})
export const queryWithUser = customQuery(query, addUser)