首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >从firebase-realtime-database过滤数据

从firebase-realtime-database过滤数据
EN

Stack Overflow用户
提问于 2018-11-06 23:44:28
回答 1查看 272关注 0票数 1

我正在尝试从firebase获取具有用户用户名的值的数据。一周前我尝试了两种不同的方法,但现在我又回来了,我注意到我已经把它删除了。

这里是我订阅数据的home.ts内部

代码语言:javascript
复制
this.database.list<EventModels>('event-list').valueChanges().subscribe((eventData) => { 

}, (err)=>{
 console.log("Error while retrieving event details : ", err);
}); 

this.eventListRef$ = this.database.list<EventModels>('event-list');
this.eventList$ = this.eventListRef$.snapshotChanges()
.pipe(
  map(changes => 
    changes.map(c => ({ id: c.payload.key, ...c.payload.val() }))
  )
);

我要过滤的数据等于创建者

由于我将creator设置为用户的电子邮件,因此我想列出仅由用户通过使用== firebase.auth().currentUser.email创建的所有事件,并且我尝试的所有事件都失败了。

EN

回答 1

Stack Overflow用户

发布于 2018-11-07 02:38:15

AngularFire documentation on querying lists

db.list('/items',ref => ref.orderByChild('size').equalTo('large'))

所以看起来你的代码应该是这样的:

代码语言:javascript
复制
this.eventListRef$ = this.database.list<EventModels>('event-list', 
  ref => firebase.database().ref("event-list").orderByChild("email").equalTo(firebase.auth().currentUser.email));
票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/53175243

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档