how to get single data from firestore collection in node js 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 data in from a collection firestore
db.collection("users").get().then((querySnapshot) => {
querySnapshot.forEach((doc) => {
console.log(`${doc.id} => ${doc.data()}`);
});