uma
uma17h ago

I want to run a custom test query like this:

import { v } from 'convex/values' // <-- Doesn't work export default query({ args: {indexName: v.id("table2")}, handler: async (ctx, args) => { //const foo = 'k97aaays4htqrgyvtcc9ngwsgn7nbkhv' as 'Id<"pods">' // <-- Doesnt work const page = await ctx.db .query("table1") .withIndex("by_some_index", q => q.eq("indexName", args.indexName )) .paginate({ cursor: null, numItems: 1000 }); return page.page.filter(m => m.isActive !== false).length } }) I have bigger problems (I could've reset my aggregates in production unknowingly..but I am trying to run custom queries first). Being able to pass Id<"tableName"> would be awesome
3 Replies
Convex Bot
Convex Bot17h 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!
uma
umaOP17h ago
Never mind: I solved this by casting a string as any
Clever Tagline
Clever Tagline13h ago
Casting a value as any is seldom a recommended solution. It essentially removes the type safety that is one of the main benefits of Convex. I can see a few issues with the example you shared above, but before getting into that it would help to know more details about what you're trying to do.

Did you find this page helpful?