具有给定成员ID的AngularFireDatabase过滤器查询

时间:2019-07-02 10:37:00

标签: angular typescript firebase firebase-realtime-database angularfire2

我在firebase(真实的tiem数据库)中拥有下一个结构

firebase database structure

不同的聊天室包含不同的成员集(ID列表) 我应该如何对查询进行编码,以仅获取在members子级中具有给定成员ID的那些聊天室?

我当前的代码:

    this.chatRooms$ = this.af.list('chat-rooms', (ref: any) =>
      ref
      .orderByChild('recentMessage/members/0').equalTo(this.authService.user.chatId) // <-- I should check all members, not /0
//      .orderByChild('recentMessage/time') // I also need to order the results, but multiple orderByChild are not supported, how to deal with this? I do not need to order by member.id, only filter..
    ).valueChanges();

或者我的结构错了,我应该再建一个结构吗?

0 个答案:

没有答案