Stevan
Stevan3y ago

Mutating Arrays

What is the recommended approach for mutating an array stored in the database? Like if I’m building up an array of followers and I want to patch the document where these followers are stored by removing a specific element and then put it back in the database. Do you just query the document at the beginning of the mutation, modify the array and then patch it back into the database?
2 Replies
jamwt
jamwt3y ago
Yes! Or use a junction table if someone might have a lot of followers. https://stack.convex.dev/relationship-structures-let-s-talk-about-schemas
Relationship Structures: Let's Talk About Schemas
In this post we’ll look at some patterns for structuring relationships in the Convex database.
Stevan
StevanOP3y ago
Okay good deal. Thank you helping me 🙏🏻

Did you find this page helpful?