Question on one to many relationship in database
I'm trying to create a database table where an item can have many user's attached to it, but i'm not sure the best way to do this with convex. Is there a way to index on an array of user ids?
It doesnt feel scalable to search all items and filter by if an id is in the array. Is there a better way to handle this relationship and make a more scalable secondary key for querying on?
items: defineTable({
people: v.array(v.id("users")),
itemName: v.string(),
})
1 Reply
Hey @greyson , check out this article:
https://stack.convex.dev/relationship-structures-let-s-talk-about-schemas
Let us know if it doesn’t answer your question
Relationship Structures: Let's Talk About Schemas
In this post we’ll look at some patterns for structuring relationships in the Convex database.