Kek*_*rov 15 firebase angular google-cloud-firestore
如何在google firestore中通过id获取文档?有一些get()方法吗?因为我搜索但没有找到适合我的正确答案:(
UPD:this.itemscollection.doc(id).get()没有为我工作
Har*_*esh 25
试试这个代码
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);
});
Run Code Online (Sandbox Code Playgroud)
在firestore上使用angular 2(在使用packageangleFire2软件包时)成功工作的关键是要知道,官方文档中所有处理单个文档(例如“ get”,“ set”,“ update”)的firestore方法都是“ ref”的子级方法示例
firestore - this.itemscollection.doc(id).get()
angularfirestore2 - this.itemscollection.doc(id).ref.get()
-------------------------------------
firestore - this.itemscollection.doc(id).set()
angularfirestore2 - this.itemscollection.doc(id).ref.set()
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
17193 次 |
最近记录: |