'Is it OK to store objects and objects' ids in separate fields in Firestore [duplicate]
I have collection of chats and I want to search through this collection by chat's members. Collection looks like:
{
...
owner: 'user-123',
members: ['user-123', 'user-456'].
membersData: [{
id: 'user-123',
name: 'Jack'
},
{
id: 'user-456',
name: 'Jane'
}
]
...
}
The reason of this that I can't search by members' ids using array-contains if members are objects. Is this solution OK? I have a very small experience in firebase (and noSQL databases generally) so may be there are best practices for this type of tasks?
Solution 1:[1]
Yup, that is completely acceptable an in fact the idiomatic approach if you want to be able to search for just member IDs.
Also see:
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Frank van Puffelen |
