How can I run the equivalent of this
How can I run the equivalent of this query
select ... where field in (list of values)
? It looks like there is no in
operator. Is the only way to build a long list of or
filters?2 Replies
Not sure if you have the same use case but maybe you will find this helpful:
https://discord.com/channels/1019350475847499849/1019350478817079338/1220796223666257980
There's no efficient way to do this in a single
db.query
(check out https://stack.convex.dev/databases-are-spreadsheets#no-efficient-in--or hot off the presses).
You can either do a separate db.query
for each thing in your list, or scan the full table and then apply the filter (either with a .filter
with a bunch of or
s, or in JavaScript, both are effectively the same performance, check out https://stack.convex.dev/complex-filters-in-convex for a deeper dive).
So something like
or
Using TypeScript to Write Complex Query Filters
There’s a new Convex helper to perform generic TypeScript filters, with the same performance as built-in Convex filters, and unlimited potential.
Databases are Spreadsheets
I want to share my mental model of databases:
- Databases are just big spreadsheets
- An index is just a view of the spreadsheet sorted by one or mor...