Firestore Getting documents id from collection

后端 未结 9 1185
陌清茗
陌清茗 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 01:05

    I have tried this

    return this.db.collection('items').snapshotChanges().pipe(
              map(actions => {       
                return actions.map(a => {
                  const data = a.payload.doc.data() as Item;
                  data.id = a.payload.doc.id;
                  data.$key = a.payload.doc.id;
                  return data;
                });
              })
            );
    

提交回复
热议问题