我有以下这段代码从一个集合中检索所有文档:
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};
});
})
);
}
那么,现在,我只做一个文件(我知道他的身份证)怎么办?
谢谢!