我想从firestore中检索数据,但我似乎无法检索它。
我的user.ts提供程序内部
getUserEventData() {
var sDoc = this.afs.doc(`users/${this.afAuth.auth.currentUser.uid}`).collection('events').doc('volunteer');
sDoc.snapshotChanges().forEach(element => {
return element.payload.data;
});
}firestore索引
I want to retrieve the name/value of "Bandar Ku Ceria" imageLink
我如何在profileUser.ts上调用它
console.log(this.userProvide.getUserEventData);我希望现在在控制台上显示"Bandar Ku Ceria“,在提供者user.ts中,我是否使用了从firestore调用数据的正确方式?帮助。
发布于 2018-10-09 12:36:02
再次检查firestore文档:https://firebase.google.com/docs/firestore/query-data/get-data
您的语法似乎来自实时数据库,但情况发生了变化。
您不能像在实时数据库中那样执行doc(用户/id)操作。你必须做db.collection('users').doc(USER_ID).collection('events').doc('volunteer')
如果您只想.get().then()一次数据...或者如果您需要实时更新
.onSnapshot(snap => {
//deal with the snapshot
})https://stackoverflow.com/questions/52712009
复制相似问题