Conditionally Building Queries
Having trouble figuring out how to do the following without TypeScript complaining.
I want to start a query like this:
And conditionally add to it. Then later for an indexed query:
Then later, an optional in memory filtering.
Something like that anyway. But I run into:
is missing the following properties from type 'QueryInitializer<{ document: { _id: Id<"requests">; _creationTime: .... etc.
8 Replies
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!
Does this pattern help?
Thanks @lee , just to make sure I'm not missing anything... to remove all TS errors I had to do something like the following:
Have I missed a more convenient way to get this done? All good either way (when I didn't specify the search index, it complained... adding it solved it... even though I'm not using the search index in my query)!
I duplicated this
https://discord.com/channels/1019350475847499849/1312453606074749061
Is not very explicit, can you share some documentation? @lee
I battled with something similar to this a few weeks ago as well. https://discord.com/channels/1019350475847499849/1282852743689535548/1301665342770249809 There's some discussion about it in this thread and a link to a lil' repo I made with my findings. Not done or thorough at all, but maybe some of its useful to you!
This looks good to me. Are you still seeing problems?
I'm checking this @djbalin, thanks.
Thanks Lee and everyone else. It's fine for now. Could definitely be made nicer, but moving on for now. 🙂