Firestore Getting documents id from collection

后端 未结 9 1181
陌清茗
陌清茗 2020-11-30 00:16

I\'m trying to retrieve my documents with id but can\'t figure it out.
Currently I retrieve my documents like this :

const racesCollection: AngularFir         


        
9条回答
  •  甜味超标
    2020-11-30 00:56

    For angular6+

        this.shirtCollection = afs.collection('shirts');
        this.shirts = this.shirtCollection.snapshotChanges().pipe(
            map(actions => {
            return actions.map(a => {
                const data = a.payload.doc.data() as Shirt;
                const id = a.payload.doc.id;
                return { id, ...data };
            });
            })
        );
    

提交回复
热议问题