【发布时间】:2020-11-04 14:43:20
【问题描述】:
我正在尝试在 Firestore 中实现文档引用。我创建了两个集合:Customers 和 Purchased-Property。每次在Purchased-Property 集合中创建新文档时,我如何在Purchased-Property_Customer_id 中引用Customer_id。
代码如下:
const CustomerDoc = firebase.firestore().collection("Customers").doc()
CustomerDoc.set({
Customer_id: CustomerDoc.id,
Customer_Name: Name
Customer_PhoneNumber: PhoneNumber
})
const PurchasedPropertyDoc = firebase.firestore().collection("Purchased-Property").doc()
PurchasedPropertyDoc.set({
Purchased_Property_id: PurchasedPropertyDoc.id,
Purchased_Property_Name: Property_Name,
Purchased_Property_Location: Property_Location,
Purchased_Property_Customer_Id: Customer_Id //How do i make reference to this Customer_Id in the Customers collection everytime a new document under the Purchased-Property collection is made
})
【问题讨论】:
标签: javascript firebase react-native google-cloud-firestore