Indexing arrays
Hello,
Not supporting array indexing or filtering is a real pain. Is it a popular opinion or is it just me?
Instead of doing something like:
ctx.db.query('products).withIndex(q => q.inArray('tags', tagId))
or
ctx.db.query('products).filter(q => q.inArray(q.field('tags'), tagId))
Over-fetching and then removing unwanted data is not possible because I have a lot of data and I must use a paginated query.
So I am forced to create a union table productXtag
and update it for each product insert/update/delete.
I have multiple cases where I need many-to-many relation and it becomes to be a real nightmare to manage them all.
Why is it not possible to index an array?
This is the first serious pitfall I encounter with Convex. This aside, Convex has the best DX I ever encountered.
--
Here is another concrete and classical example:
I have a categories
and a products
table.
--> I need an efficient way to get all paginated products in category A
, including all products in its descendants categories (B
, C
).4 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!
Nobody interested in this?
I wonder the same thing. I might have asked something similar a while ago, but I’m not sure. I’ll try to look later.