![]() If you want to get the reservation only of a single type (manager or client), you should use a query that might look like this: db.collection("reservations").whereEqual("type", "manager") Īs you can see, I have also added a date property so you can easily sort them descending (last reservation first). You can also get all reservations by adding a reference on reservations collection. Using this schema, you can simply query the database to get all users or specific users (manager or clients). I'll try to provide you a schema that can help you get that data very easily. And each client should be able to see his history of reservations as well. The restaurant´s management should be able to see his reservation together with other reservations from other clients, in a list. You won't always want to query your reservations by restaurant, maybe you want to pull by user or time, etc. Instead of a collectionGroup query which would call for all restaurants' sub collection list of reservations. With this structure you can very easily just call:Īll reservations by user X or All foods meeting nutrition limits of Y You will find you'll want to store data multiple times and this to me feels like a good structure for it. who knew STARTERS TEMPURA OYSTER MUSHROOMS With Parmesan and truffle oil 8. It was 571 feet tall and was the largest structure of its type in the world. This is good so if you request all reservations, you'll get the restaurant's name and ID, etc. STARTERS The Ruston Smoke Stack was built in 1917 and taken down in 1993. ![]() What you'll notice is there is some redundant info. ![]() I think the optimal structure is: Restaurants (collection) It's a personal preference from working with a lot of nested collections. It's easy enough to take a restaurantID and stick it in the each document in those collections, so I don't personally think you should nest them in the Restaurants collection. I think storing Foods and Reservations as top level collections will ultimately yield you more flexibility later on.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |