Firestore通过Angular 2上的ID获取文档 [英] Firestore get document by id on angular 2
本文介绍了Firestore通过Angular 2上的ID获取文档的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在Google Firestore中按ID获取文档?有一些get()
方法吗?因为我搜索了但没有找到适合我的正确答案:(
How to get document by id in google firestore? is there some get()
method? because I searched but didn't find a proper answer that suits to me :(
更新: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);
});
这篇关于Firestore通过Angular 2上的ID获取文档的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文