1

I am new to Firestore cloud and I am trying to learn about it. I am trying to build a project and I am stuck at one point.

My Firestore database looks like this: enter image description here

enter image description here

I have a Groups collection that has "Users List" Sub-collection" where I have "timestamp" and "user_id". When I created a group I grabbed the user_id of the "user" that creates a group and added that in "Users List". Now I am looking to retrieve all the "Groups"(groupName) that the "CurrentUser" is involved in, and I am having hard time to figure it out because I found that NoSQL databases are very different from SQL databases. Would be great if someone can shed a light on this matter. Thank you

B.B.KinG
  • 35
  • 4

1 Answers1

0

I'm not sure about this, but I think your best bet is to add some field to collect group that each user involve in "Users" Collection using array or object to collect it since Firestore can collect array or object.

But TBH, I not sure this is the best, but it is the best I can think rightnow. Because with these you only need to query 1 time for each user that you want to get usergroup and it help you to not use lots of query to get usergroups for each user. But it will couse you some additional size. But it still fine since Firestore costing is base on both query and size for this case. Little(?) additional data is better than waste lots of query to get usergroup for only one user.

Hello World
  • 740
  • 5
  • 18