Firebase Firestore的复杂数据模型
我正在用Firestore+angularfire构建我的第一个应用程序,由于我缺乏Firestore的经验,很难定义数据模型。我需要你的帮助 我有以下实体和依赖项Firebase Firestore的复杂数据模型,firebase,data-modeling,google-cloud-firestore,Firebase,Data Modeling,Google Cloud Firestore,我正在用Firestore+angularfire构建我的第一个应用程序,由于我缺乏Firestore的经验,很难定义数据模型。我需要你的帮助 我有以下实体和依赖项 餐厅:它们是独立的,可以由应用程序的用户注册 创建餐厅的用户成为“所有者”。他/她可以邀请其他用户成为餐厅的“服务员/服务员” 用户可以收到来自一家或多家餐厅(可能来自不同的店主)的“做我的服务员/服务员”邀请 我们还有另一个“客户”实体。该实体的条目包含有关订购的菜肴和饮料、价格、小费等的数据 然后是以下规则 每位店主都可以在其餐
您能帮我解决这个问题,并提供一些您认为使用Firestore规则管理它的最佳方式的想法吗???这是一个基于您所说的建议:
Restaurants
[id] (document)
owner: idUser(Owner)
waiters (map)
idUser1: timestamp
idUser2: timestamp
idUser3: timestamp
customersIn (collection)
[idCustomer1]
itens: (map)
french fries: 10
water: 3
[idCustomer2]
itens: (map)
hot dog: 6
soda: 4
Customers
[id] (document)
name
restaurants (map)
idRestaurant1: timestamp
idRestaurant2: timestamp
Users
[id] (document)
waiterIn (map)
idRestaurant1: timestamp
idRestaurant2: timestamp
当您尝试对其进行筛选和排序时,此aproach在中被注释
在这种情况下,你可以像餐厅的顾客、一家餐厅的服务员或服务员所在的餐厅那样提出任何疑问。
像这样:
customersRef.where("restaurants." + idRestaurant, '>', 0).orderBy("restaurants." + idRestaurant);
希望这有帮助