[英]Google Firestore data organization
As I can see Cloud Firestore and it's collections give us much more power to organize data. 如我所见,Cloud Firestore及其集合为我们提供了更多组织数据的能力。 For me and many others, I think, there's a basic question.
对于我和其他许多人,我认为这是一个基本问题。
What's the better approache to store a master detail relation? 存储主细节关系的更好方法是什么?
Like this : a "CARS" collection with documents that have a "MAKE" property. 像这样:一个带有“ MAKE”属性的文档的“ CARS”集合。
I think that I need a "CARS" collection and an independent collection for "MAKES". 我认为我需要一个“ CARS”收藏品和一个单独的“ MAKES”收藏品。
Any thoughts ? 有什么想法吗 ?
Unless you have a specific need, you might be better off just have MAKE as a field each CARS document so you can query for it. 除非有特定需要,否则最好将MAKE作为每个CARS文档的字段,以便您进行查询。
If you want to control MAKE as an enumerated field, you can create a collection called ValidMakes that has documents with ids of all the allowed Makes. 如果要将MAKE控制为枚举字段,则可以创建一个称为ValidMakes的集合,该集合的文档的ID为所有允许的Makes。 In security rules, check that there exists a document with the same id as the MAKE field's value before allowing the write.
在安全规则中,在允许写入之前,请检查是否存在与MAKE字段的值具有相同ID的文档。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.