问题
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
Thankyou for the help.
回答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.
来源:https://stackoverflow.com/questions/48247511/how-to-get-a-document-from-a-collection-based-on-a-particular-field-in-that-docu