Firestore 是否可以检索文档名称未知或唯一 ID 的文档中的数据。就像在链接的图像中一样。ID未知而名称已知,在这种情况下是否可以获取ID?
db.collection("users").document(??).collection("John Doe");
您将需要一个名称查询:
var peopleRef = db.collection("users");
// there may multiple users if there are more then one `John Doe`
peopleRef.where("name", "==", "John Doe")
.get()
.then(function(querySnapshot) {
querySnapshot.forEach(function(doc) {
//Here below will list all people who's name = "John Doe", If only one then this John Doe's id no: doc.id as fallow:
console.log(doc.id, " => ", doc.data());
});
})
.catch(function(error) {
console.log("Error getting documents: ", error);
});
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句