Answers for "how to fetch document based on condition from cloude firestore"

11

how to query in firestore

db.collection("cities").where("capital", "==", true)
    .get()
    .then(function(querySnapshot) {
        querySnapshot.forEach(function(doc) {
            // doc.data() is never undefined for query doc snapshots
            console.log(doc.id, " => ", doc.data());
        });
    })
    .catch(function(error) {
        console.log("Error getting documents: ", error);
    });
Posted by: Guest on May-28-2020
4

get data in from a collection firestore

db.collection("users").get().then((querySnapshot) => {
    querySnapshot.forEach((doc) => {
        console.log(`${doc.id} => ${doc.data()}`);
    });
Posted by: Guest on December-11-2020

Code answers related to "how to fetch document based on condition from cloude firestore"

Browse Popular Code Answers by Language