我對 Firestore 很陌生。我有這個查詢顯示聊天消息和新消息出現時的更新。我只希望當前用戶(學校)看到來自他們自己學校的消息。如果我不包含 .where 子句 - 它會顯示所有消息,但如果我使用它則不會顯示任何內容(即使它們存在)這是我的 firestore 頁面圖像的鏈接(因為我無法嵌入它):我在掛載上調用方法:mounted() { //fetches the messages this.fetchMessages(this.$route.params.id);},那么方法是:fetchMessages(schoolsIdentification) { db.collection('chat') .where("user.schoolId", "array-contains", schoolsIdentification) .orderBy('date') .onSnapshot((querySnapshot) => { let allMessages = []; querySnapshot.forEach(doc => { allMessages.push(doc.data()) }) console.log("the all messages array length is:", allMessages.length) this.messages = allMessages; })}我在這里做錯了什么嗎?
在 Vue 中使用 Firestore,.where 不返回任何結果 - 但它們存在
慕容3067478
2023-05-25 15:25:15