【问题标题】:AngularFire2 orderByChild Query UnsuccessfulAngularFire2 orderByChild 查询不成功
【发布时间】:2019-02-04 05:06:16
【问题描述】:

我想我在 Angularfire2 查询方面遗漏了一些东西。我收到以下错误:

ERROR TypeError: db.list(...).orderByChild is not a function

这是我产生的错误:

this.itemsRef = db.list('projects/').orderByChild('buyerEmail').equalTo(user.email);

this.items = this.itemsRef.snapshotChanges().pipe(
  map(changes => 
    changes.map(c => ({ key: c.payload.key, ...c.payload.val() }))
  )
);

这个,但是返回我试图深入研究的列表:

this.itemsRef = db.list('projects/');

this.items = this.itemsRef.snapshotChanges().pipe(
  map(changes => 
    changes.map(c => ({ key: c.payload.key, ...c.payload.val() }))
  )
);

JSON:

 projects
    -LXpud3uxRaTHKIRa4Da
          ProjectName: "1234 sesame st."
          buyerEmail: "matt@theInternet.com"
    -LXpud3uxRaTHygr56aT
          ProjectName: "789 sesame st."
          buyerEmail: "joe@theInternet.com"

任何帮助将不胜感激。

编辑: 事实证明这是解决我的问题的错误方法。我最终保存了我想要的“密钥”并使用它来查找对象。在这种情况下无需查询列表。

【问题讨论】:

    标签: angular firebase ionic-framework firebase-realtime-database angularfire2


    【解决方案1】:

    对于 list ,以下可能有效。

    this.itemsRef = db.list(path , {
      query: {
        orderByChild: 'buyerEmail',
        equalTo: user.email,
      }
     });
    

    【讨论】:

    • 不幸的是,它似乎没有。我猜这可能是 Ionic 4 的问题。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-03-11
    • 1970-01-01
    • 1970-01-01
    • 2020-09-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多