I\'m trying to insert a document into a collection. I want the document to have a attribute of type reference
to insert into the collection. But every time I in
I was trying to figure this out today and the solution I came to was to use the .doc()
to create a doc reference
firebase.firestore()
.collection("applications")
.add({
property: firebase.firestore().doc(`/properties/${propertyId}`),
...
})
This will store a DocumentReference type on the property
field so when reading the data you will be able to access the document as so
firebase.firestore()
.collection("applications")
.doc(applicationId)
.get()
.then((application) => {
application.data().property.get().then((property) => { ... })
})