firebase - 我想在 Fire 商店中创建客户集合,并且我希望发票与 firebase 中的该集合相关联
问题描述
客户:[{名称:“helloWorld”,电话:123,地址:“address1”,发票:[{ product1:“sa”,价格:“4500”,totalAmount:123,},{ product1:“Bca”,价格:"2600", totalAmount:2500, } ]
},
{名称:“NewCus”,电话:788888888,地址:“address2”,发票:[{ product1:“ase2”,价格:“6500”,totalAmount:9000,},{ product1:“Bca”,价格:“bha ", 总金额:2500, } ]
}
],
解决方案
有很多方法可以做到这一点。一种选择是从用户集合开始
users
uid_0 //john's uid from their auth object
name: "John"
uid_1
name: "Paul"
然后发票存储在发票集合中,并引用用户 uid
invoices
invoice_0
amount: "$100"
user: "uid_0"
invoice_1
amount: "$50"
user: "uid_0"
invoice_2
amount: "$22"
user: "uid_1"
综上所述,用户 John 有两张发票;100 美元和 50 美元,uid_1 在发票上有一张 22 美元
根据您要运行的查询,您还可以在用户文档中存储用户发票列表。
users
uid_0 //john's uid from their auth object
name: "John"
invoices:
invoice_0: true //true is a placeholder value
invoice_1: true
推荐阅读
- reactjs - 使用 Reactjs 切换侧边栏菜单
- jquery - 在 Gatsby 中使用 jQuery 和外部脚本
- jquery - jQuery Next 直到当前状态隐藏/显示子 TR
- ssh - 在 Airflow 的 python_callable 中执行 SSH 连接?
- java - Activity 和 Fragment 之间的接口自动变为 null
- c# - 如果值与给定模式匹配,则查找 JToken
- haskell - 如何识别 Servant 所需的扩展
- python - 定位 Tkinter 复杂网格
- javascript - 使用 Javascript 获取 HTML 元素中的 innerText 字段的值
- python - 等待加载圈消失的等待函数 selenium,unittest,python 即使圈已经完成加载也需要 12 秒以上