【发布时间】:2018-01-14 07:27:30
【问题描述】:
const docRef = firestore.collection("orders").document("")
如果字段值为Admno:“11.11.1111”,我需要获取文档“147OiRKFYKA3WAo5d5mk”
这是我的数据库
感谢您的帮助。
【问题讨论】:
标签: javascript firebase google-cloud-firestore
const docRef = firestore.collection("orders").document("")
如果字段值为Admno:“11.11.1111”,我需要获取文档“147OiRKFYKA3WAo5d5mk”
这是我的数据库
感谢您的帮助。
【问题讨论】:
标签: javascript firebase google-cloud-firestore
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);
});
如果您刚开始使用 Firestore,我强烈建议您阅读 the documentation。
【讨论】:
const docRef = firestore.collection("orders").document(doc.id);,因为我收到一个错误Uncaught (in promise) TypeError: firestore.collection(...).document is not a function 在代码行docRef.add({
document() 不是函数。你必须使用const docRef = firestore.collection("orders").doc(doc.id);
doc() 函数