答案 0 :(得分:1)
使用angularfire2,您可以执行以下操作:
this.itemDoc = afs.doc<any>('/lists/432jk....'); //You know the "the current user's id", then you can build the document ref (i.e. path)
this.item = this.itemDoc.valueChanges();
this.item.subscribe(value => {
const urlsArray = value.urls;
});
文档中的更多详细信息:https://github.com/angular/angularfire2/blob/master/docs/firestore/documents.md
或者您可以按如下方式使用本机JavaScript SDK:
var docRef = db.collection('lists').doc('/lists/432jk....');
docRef.get().then(function(doc) {
if (doc.exists) {
const urlsArray = doc.data().urls;
} else {
// doc.data() will be undefined in this case
console.log("No such document!");
}
}).catch(function(error) {
console.log("Error getting document:", error);
});