[英]How to get the results of a query as an Object from Cloud Firestore?
[英]how to get the response object from a single query in cloud firestore using nodejs?
我正在尝试在 cloud firestore 中查询并尝试提取文档 ID,并且还有另一个值也称为 cc 我能够提取信息但 using.forEach 但我想问是否有另一种方法可以做到这一点是我的询问
const recipient = await db
.collection("Active")
.where("office", "==", "d")
.where("template", "==", "dt")
.where("attachment.Name.value", "==", "xyz")
.get();
const id = [];
const cc = [];
recipient.forEach((doc) => {
id.push(doc.id);
cc.push(doc.data().cc);
// console.log(JSON.stringify(doc.data()));
});
如果查询结果中只有一个文档,
const recipient = await db.collection("Active").where("office", "==", "d").where("template", "==", "dt").where("attachment.Name.value", "==", "xyz").get(); const id = []; const cc = []; id.push(recipient.docs[0].id); cc.push(recipient.docs[0].data().cc);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.