If I want to get a firebase document reference to use it in a filter for another query:
.where('project', '==', projectDocRef)
to get the project reference is equivalent to do:
projectDocRef = snapshot.ref;
and
proyectDocRef = firestore.collection('projectcolection').doc(snapshot.id);
?
Does any of the alternatives have any advantages?
No, 1st method can be used only when you've fetched the document already and have its DocumentSnapshot. Using ref would convenient here.
When you don't have a DocumentSnapshot, then you would have to use.doc() to get a DocumentReference.
You can remove.collection() just yo reduce some code like:
proyectDocRef = firestore.doc('projectcolection/docID')
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.