用匹配的电子邮件通过每个客户是不起作用的
db.collection("organization")
.doc(glob_orgID)
.get()
.then((snapshot) => {
const n_email = snapshot.data().owneremail;
console.log("new email from param2 =" + n_email);
glob_email = n_email;
db.collection("customers")
.where("email", "==", glob_email)
.onSnapshot((querySnapshot) => {
var cust = [];
querySnapshot.forEach((doc) => {
// cust.push(doc.data().customerId);
console.log("foreach data = ", doc.ref.id);
return null;
});
console.log("Current email is : ", glob_email);
console.log("Current cust with join : ", cust.join(","));
});
console.log("doc exists + " + snapshot.exists);
return "doc exists:" + snapshot.exists;
})
.catch((err) => {
console.error("Error getting customers doc", err);
process.exit();
});
console.log("WTF happended???");
});
您需要对映射中的每个项使用doc.data()
方法。。请尝试:
querySnapshot.map((doc) => {
console.log(doc.data());
return null;
});