MietzeKatze
MietzeKatze•3w ago

how do i define a schema that links to a better auth component table user, id field ?

I want to do this:
tasks: defineTable({
text: v.string(),
isCompleted: v.boolean(),
userId: v.id("user") <--- better-auth component table
}),
tasks: defineTable({
text: v.string(),
isCompleted: v.boolean(),
userId: v.id("user") <--- better-auth component table
}),
but the convex better-auth component has its own scope and I cant seem to be able to link to it.... or is there a different syntax?
3 Replies
Sara
Sara•3w ago
Use type string, and find the user by id using getAnyUserById or something like that 😂
erquhart
erquhart•3w ago
Yeah id validation doesn't work across the component boundary, have to use v.string() for ids written by a component.
xTazy
xTazy•2w ago
@erquhart need to add it to docs, and mention that we can use triggers to replicate the user to main db

Did you find this page helpful?