#.
3 messages · Page 1 of 1 (latest)
Hi @mystic matrix. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
No, you currently cannot index array values directly in Convex (for example, you can’t have an index that lets you efficiently query “documents where tags array contains X”). [Many-to-many arrays; Array indexing thread]
Because of this:
-
Using an array field is fine when:
- You only need to read the array from the owning document, and
- You don’t need to efficiently query “who has this element in their array,” and
- The arrays stay relatively small. [Many-to-many arrays]
-
If you do need efficient lookups by an element (e.g. “all users with choice X”, “all products with tag Y”), the recommended pattern is a separate join/relationship table (e.g.
{ userId, choiceId }) with indexes on those scalar fields. [Many-to-many arrays; Array indexing thread]