I'm running multiple queries on Firebase Firestore. They all (can) return an Observable. I would like to combine all Observable into ONE Observable.
I have tried different RxJS operators, like; combineLatest, forkJoin, concat, zip, merge and mergeMap. But I have not been able to achieve the desired result.
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 above piece of code I get all the private books from authors[0]. When I return concat(...bookRefs) or concat(bookRefs[0], bookRefs[1]), I still only get the books from authors[0]. I expect to get all the books from all the authors provided.