【发布时间】:2018-03-29 18:29:58
【问题描述】:
我创建的应用程序的结构如下所示。当前结构仅适用于一家公司。
let current = {
products: {
product1: {}//...
},
customers: {
customer1: {},// ...
},
orders: {
order1: {},// ...
},
}
现在我设计了数据结构,使其成为多公司应用程序。假设公司是ABC、PQR、XYZ,但客户是相同的。因此,客户可以看到来自不同公司的产品。
选项 1:在每个列表文档中添加公司属性。
let option1 = {
company: {
products: {
product1: {
company: 'ABC'
},
},
customers: { //Also we can put it at root with field company as array. Customers are not primary concern
customer1: {
company: 'PQR'
}
},
orders: {
order1: {
company: 'ABC'
}
},
}
}
我的评论:我必须将公司财产放在每个可能比这些更多的列表中。它看起来不像是正确的解决方案。查询不同公司的产品看起来很容易。
选项 2:复制不同公司的当前根结构。
let option2 = {
company1: {
products: {
product1: {}
},
customers: {//Also we can put it at root with field company as array. Customers are not primary concern
customer1: {},
},
orders: {
order1: {},
},
},
company2: {
products: {
product1: {}
},
customers: {
customer1: {},
},
orders: {
order1: {},
},
},
// ...
}
我的评论:我不知道 Firestore 的限制和即将推出的功能。查询不同公司的产品可能并不容易。
let option3= {} //your suggestions.
在同一个 Firestore 项目中,假设客户处理不会有问题。
这里可以做什么?我缺少什么?
【问题讨论】:
标签: firebase data-structures firebase-realtime-database google-cloud-firestore