【发布时间】:2021-01-17 07:30:58
【问题描述】:
我的 Firebase Firestore 中有以下结构:
是否可以仅查询第二张图片中间列中显示的文档 ID?这是我当前的查询,在我看来这是最合乎逻辑的方式。 console.log 返回成功信息,但数组为空:
async function getListofPosts() {
try{
return await useFireStore
.collection('chats')
.doc(`${postId}`)
.collection('chat')
.get().then(res => {
let theMessageList = [];
res.forEach(doc => {
theMessageList.push(doc.data(), doc.id )
});
setMessageList(theMessageList);
});
}
catch {
console.log('error on getListofPosts')
}
finally {
console.log('getListofPosts worked')
}
}
非常感谢任何帮助。 干杯,马特
【问题讨论】:
标签: firebase google-cloud-firestore