I'm trying to implement documentreference in firestore. I created two collections : Customers and Purchased-Property. How can i reference the Customer_id in the Purchased-Property_Customer_id everytime a new document is created in the Purchased-Property collection.
The code is shown below:
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
})