How To Get A Document From A Collection Based On A Particular Field In That Document
const docRef = firestore.collection('orders').document('') I need to get the document '147OiRKFYKA3WAo5d5mk' if the field value is Admno:'11.11.1111' here is my database Thankyo
Solution 1:
This case is mentioned in the official Firestore documentation:
db.collection("orders").where("Admno", "==", "11.11.1111")
.get()
.then(function(querySnapshot) {
querySnapshot.forEach(function(doc) {
console.log(doc.id, " => ", doc.data()); //here's your doc
});
})
.catch(function(error) {
console.log("Error getting documents: ", error);
});
I strongly recommend reading the documentation if you're getting started with Firestore.
Post a Comment for "How To Get A Document From A Collection Based On A Particular Field In That Document"