【发布时间】:2020-10-19 13:34:58
【问题描述】:
我对 Firestore 还是很陌生。我有这个查询,当新消息出现时显示聊天消息和更新。我只希望当前用户(学校)看到他们自己学校的消息。如果我不包含 .where 子句 - 它会显示所有消息,但如果我使用它则什么也不会显示(即使它们存在)
这是指向我的 Firestore 页面图像的链接(因为我无法嵌入它):
我在 mount 上调用方法:
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;
})
}
我在这里做错了吗?
【问题讨论】:
标签: javascript vue.js google-cloud-firestore