Angular Firestore: What Is The Correct Syntax For A Collection Query That Uses A Where Clause?
I have working code that queries Firestore and returns an Observable of type ImageUploadWId[]. I would like to return a Promise instead. This is because my data isn't changing of
Solution 1:
AngularFire2 wraps the Firebase reference, so calling .ref.get()
creates a new reference and ignores the query function you supplied.
Luckily, RxJS makes it easy to convert an Observable to a Promise. You just need to pipe in first()
or take(1)
to force the Observable to complete (otherwise the promise will never resolve because Firebase provides an endless realtime stream).
returnthis.afs.collection(...)
.valueChanges()
.pipe(first())
.toPromise()
Post a Comment for "Angular Firestore: What Is The Correct Syntax For A Collection Query That Uses A Where Clause?"