Firebase Firestore:检查snapshot.exists始终返回false,即使集合中存在文档
这是我的Firestore设置。如您所见,此集合中有文档。 这是我获取集合中文档快照的代码。它总是返回错误。有人能帮我弄清楚怎么修吗Firebase Firestore:检查snapshot.exists始终返回false,即使集合中存在文档,firebase,google-cloud-firestore,Firebase,Google Cloud Firestore,这是我的Firestore设置。如您所见,此集合中有文档。 这是我获取集合中文档快照的代码。它总是返回错误。有人能帮我弄清楚怎么修吗 firebase.firestore().collection("chatMessages").doc("chatMessages").collection(chatId).get() .then((snapshot) => { if (snapshot.exists) { // <- alway
firebase.firestore().collection("chatMessages").doc("chatMessages").collection(chatId).get()
.then((snapshot) => {
if (snapshot.exists) { // <- always returning false
console.log("snapshot exists");
}
})
}
firebase.firestore().collection(“chatMessages”).doc(“chatMessages”).collection(chatId.get())
。然后((快照)=>{
如果(snapshot.exists){/查询没有.exists
属性——这是文档快照的属性,而不是查询快照的属性。我想您应该:
详情请参阅本页-
if (!snapshot.empty) {
console.log('query returned results');
}