How do you save a reference to another collection within Firebase Firestore? The docs on adding data doesn't mention anything about saving references.
Firestore supports storing of a reference to a document (DocumentReference
) rather than to a collection, but you can add a DocumentReference
to the database just like any other supported data type, something like this in JavaScript:
db.collection("cities").doc("LA").set({
name: "Los Angeles",
state: db.collection("states").doc("CA"),
country: "USA",
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With