如何在 google firestore 中通过 id 获取文档?有没有一些 get()
方法?因为我搜索过但没有找到适合我的正确答案:(
更新:this.itemscollection.doc(id).get()
对我不起作用
最佳答案
试试这段代码
this.itemscollection.doc(id).ref.get().then(function(doc) {
if (doc.exists) {
console.log("Document data:", doc.data());
} else {
console.log("No such document!");
}
}).catch(function(error) {
console.log("Error getting document:", error);
});
关于angular - Firestore 在 Angular 2 上按 id 获取文档,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47224976/