Reputation: 583
I'm quite new to NoSQL, that's why I come here to get your opinions.
I'm trying to understand if it's better to use nested object or subcollections in a specific case. I will try to explain my case.
I have to store several shops in my Db. Each shop will have an address, a phone number etc... So I have a Collection "Shop" and inside several Documents representing the shops. Now, my shops have some contacts (2,3 or 4 employees for example). My question is, what should I do :
objectContact: {
name: "Georges",
age: 20....
}
Which is the better ? Does one of this two solutions disable some tools/queries in NoSQL ? Does one of this two solutions is faster when it comes to write/read the data ?
Thanks in advance,
Upvotes: 1
Views: 519
Reputation: 429
Currently, all the queries in the cloud firestore are shallow which means you can't get the subcollection with its collection.You have read it separately. So I would recommend you to store it in a nested document. But it has few limitations though. Check this link for detailed explanation of modelling data in cloud firestore
Upvotes: 2