0

I would like to know if what I do is right or not, please. Given that I'm starting to have a lot of collections in my root folder, I start to change the architecture of my database:

Instead of something like that:

|_ users
|_ workouts
|_ marketplaceVendors
|_ marketplaceProducts
|_ marketplaceCoupons

Something like that:

|_ users
|_ workouts
|_ marketplace
         |_ data
                |_ vendors
                |_ products
                |_ coupons

Is it bad practice or is it totally okay?

Alex Mamo
  • 130,605
  • 17
  • 163
  • 193
KevinB
  • 2,454
  • 3
  • 25
  • 49

1 Answers1

1

I would like to know if what I do is right or not

There is no "perfect", "the best" or "the correct" solution for structuring a Cloud Firestore database. We are usually structuring a Firestore database according to the queries that we intend to perform. So you should use an architecture and build the structure of your app according to your particular use case. So if you have a clear picture of what the queries should be, then building the database schema might be very easy.

There is nothing wrong with using those 5 top-level collections, as it's also nothing wrong with nesting those 3 collections under a "data" document. Please also note that according to Firestore quotas:

Maximum depth of subcollections: 100

So in my opinion, you can go ahead with any of those schemas, as long as you get the desired results.

Alex Mamo
  • 130,605
  • 17
  • 163
  • 193