naveedehmad
naveedehmad2mo ago

having a weird type error on the `email` index on user

for some reason on users table when i try to query on the index email i'm getting Argument of type 'string' is not assignable to parameter of type 'never'error. here's my user schema:
users: defineTable({
firstName: v.string(),
lastName: v.string(),
name: v.string(),
email: v.string(),
status: v.optional(v.union(v.literal('active'), v.literal('invited'), v.literal('disabled'))),
}).index('email', ['email']),
users: defineTable({
firstName: v.string(),
lastName: v.string(),
name: v.string(),
email: v.string(),
status: v.optional(v.union(v.literal('active'), v.literal('invited'), v.literal('disabled'))),
}).index('email', ['email']),
and i have this query:
const existingUser = await ctx.db
.query('users')
.withIndex('email', (q) => q.eq('email', args.profile.email))
.unique();
const existingUser = await ctx.db
.query('users')
.withIndex('email', (q) => q.eq('email', args.profile.email))
.unique();
i'm getting type error on the index field for whatever reason. any help would be appreciated.
2 Replies
Convex Bot
Convex Bot2mo ago
Thanks for posting in <#1088161997662724167>. Reminder: If you have a Convex Pro account, use the Convex Dashboard to file support tickets. - Provide context: What are you trying to achieve, what is the end-user interaction, what are you seeing? (full error message, command output, etc.) - Use search.convex.dev to search Docs, Stack, and Discord all at once. - Additionally, you can post your questions in the Convex Community's <#1228095053885476985> channel to receive a response from AI. - Avoid tagging staff unless specifically instructed. Thank you!
naveedehmad
naveedehmadOP2mo ago
okay, this is because i was querying the user from within the convexAuth under the createOrUpdateUsercallback. i only needed to move it to a model and all good. learning new thing every day with convex. convex is heavily opinionated and i like it but please make documentation robust as well. it's nowhere explained clearly or atleast i couldn't find such pattern

Did you find this page helpful?