【发布时间】:2020-02-27 22:26:02
【问题描述】:
我正在尝试使用 angularfire2 从我的 Firestore 数据库中检索数据。 这就是我当前的数据库的样子。我有一个用户集合,其中包含将 userDetails 和 userPosts 绑定在一起的 userId 文档。
但是,当我查询此集合时,它会在控制台中返回一个空数组。
我正在使用 firebase 函数来检索数据。
Firebase 函数索引.ts
export const getFeed = functions.https.onCall(async (req,res) =>{
const docs = await admin.firestore().collection('users').get()
return docs.docs.map(doc => {
return {
postID: doc.id,
...doc.data()
}
})
})
TS 文件
tabTwoFeedInit (){
const getFeed = this.aff.httpsCallable('getFeed')
this.ajax = getFeed({}).subscribe(data=> {
console.log(data)
this.posts = data
})
}
我怎样才能成功地从这个 firebase 数据库中检索数据?
【问题讨论】:
标签: node.js firebase google-cloud-firestore firebase-admin