snapshot.data.data() cloud firestrore code example
Example 1: firestore get all documents in collection
db.collection('documents')
.get()
.then(querySnapshot => {
const documents = querySnapshot.docs.map(doc => doc.data())
})
db.collection('documents')
.doc(documentId)
.get()
.then(snapshot => {
const document = snapshot.data()
})
Example 2: get doc id firestore
const racesCollection: AngularFirestoreCollection<Race>;
return racesCollection.snapshotChanges().map(actions => {
return actions.map(a => {
const data = a.payload.doc.data() as Race;
data.id = a.payload.doc.id;
return data;
});
});