I am currently running multiple queries on Firebase Firestore, each of which has the potential to return an Observable. My goal is to combine all these Observables into a single one.
Despite experimenting with various RxJS operators such as combineLatest, forkJoin, concat, zip, merge, and mergeMap, I have not yet been successful in achieving the desired outcome.
getPrivateBooksFromAuthors(authors): Observable<Book[]> {
let bookRefs: Observable<Book[]>[] = [];
authors.map(key => {
bookRefs.push(this.afs.collection<Book>('books', ref =>
ref.where('public', '==', false)
.where('authors', 'array-contains', key)
).valueChanges())
});
return bookRefs[0]
}
In the provided code snippet, I am retrieving private books from authors[0]. Despite attempting to use concat(...bookRefs) or concat(bookRefs[0], bookRefs[1]), I continue to only receive books from authors[0]. My expectation is to obtain all the books from all the provided authors.