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?
CodePudding user response:
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')