RxJS 和 Firestore - 将文档 ID 列表映射到文档

RxJS & Firestore - map list of document ids to the documents

我在我的数据库中存储了用户喜欢的帖子的 IDS 列表,现在我想显示他喜欢的帖子列表。

我正在尝试使用 RXJS 将 IDS 映射到帖子。

到目前为止,我得到了快照中的 ID 列表,但我不确定如何将它们切换到文档本身:

myLikedConfessions() {
    return this.db.doc(this.USER_COLLECTION)
      .collection('likedConfs',
          ref => ref.limit(5))
      .snapshotChanges()
      .mergeMap((ids) => {
        console.log(ids);
 // each id should have the observable result of: this.db.collection('posts').doc(docID);

          return Observable.of({});
      })
  }

有什么想法吗?

只需使用 forkJoin 等待所有源 Observables 完成:

...
.mergeMap((ids) => {
  const observables = ids.map(id => this.db.collection('posts').doc(id))
  return Observable.forkJoin(observables)
})