gpt4 book ai didi

javascript - 如何根据文档中的特定字段从集合中获取文档

转载 作者:行者123 更新时间:2023-11-30 14:50:17 24 4
gpt4 key购买 nike

const docRef = firestore.collection("orders").document("")

如果字段值为 Admno:"11.11.1111",我需要获取文档“147OiRKFYKA3WAo5d5mk”

这是我的数据库 screenshot of database

谢谢你的帮助。

最佳答案

此案例在 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);
});

强烈推荐阅读the documentation如果您要开始使用 Firestore。

关于javascript - 如何根据文档中的特定字段从集合中获取文档,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48247511/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com