im trying to make a sort of chat app with the following architecture:
Its currently working as follows: in a root doc, there is an array of chat objects. Each chat object spawns a message doc, which contains an array of message objects. Same logic for comments.
Im thinking about a function to update all posts relative to the associated user, IE if a user changes their name all associated comments will be updated. Is this possible with the WhereIn() function? Or should i edit the architecture to something more like each document being its own message/comment? Thanks!
CodePudding user response:
An in
clause checks if a specific field is equal to one of a set of values, which doesn't apply here.
You might be thinking of array-contains
, but that wouldn't work in your current structure either. The array-contains
only matches exact an item in the array if it completely/exactly matches the value in the query.
The common way to allow such a query is to add a participants
array field to each document where you store the UIDs of all participants in that doc. Then you can do an array-contains
query against that.