如何在Firebase和Ionic中从集合中检索一个文档?

时间:2020-02-18 11:53:21

标签: angular firebase ionic-framework google-cloud-firestore

我有以下这段代码从一个集合中检索所有文档:

public postCollection: AngularFirestoreCollection<Post>;
public posts: Observable<Post[]>;

constructor(private firestore: AngularFirestore, public afAuth: AngularFireAuth) {
   this.postCollection = firestore.collection<Post>('Posts');
}

ngOnInit() {
    this.posts = this.postCollection.snapshotChanges().pipe(
        map(actions => {
          return actions.map(a => {
            const data = a.payload.doc.data();
            const id = a.payload.doc.id;
            return {id, ...data};
          });
        })
    );
}

那么,现在,我只做一个文件(我知道他的身份证)怎么办?

谢谢!

0 个答案:

没有答案