Map items of collection snapshot in Firebase Firestore

前端 未结 5 379
面向向阳花
面向向阳花 2020-12-24 11:39

Firebase Firestore Guides show how to iterate documents in a collection snapshot with forEach:

db.collection(\"cities\").get().then(function(que         


        
5条回答
  •  醉梦人生
    2020-12-24 12:13

    The answer is:

    querySnapshot.docs.map(function(doc) {
      # do something
    })
    

    The Reference page for Firestore reveals the docs property on the snapshot.

    docs non-null Array of non-null firebase.firestore.DocumentSnapshot

    An array of all the documents in the QuerySnapshot.

提交回复
热议问题