【问题标题】:how to fetch data from firebase based on particular value in a node如何根据节点中的特定值从firebase获取数据
【发布时间】:2015-02-18 05:13:18
【问题描述】:

我有如下的firebase数据库

项目主节点

|

 -DS

  |
  ----6125675
  |     |
  |      ----department:"xyz"
  |       --projectname:"sad"

  |
  -----72671273
  |       |
  |         --department:"das"
  |         --projectname:"iuh"

  |
  -----7863873
          |
           --projectname:"sad"
              department :"xyz"

现在如何在 department="xyz" 处获取部门数据。

【问题讨论】:

    标签: ios firebase firebase-realtime-database


    【解决方案1】:

    您的答案在 FB 文档中是正确的。在这里查看:https://www.firebase.com/docs/web/guide/retrieving-data.html#section-queries 并查看 orderByChild 与另一个过滤器(如 endAt)的结合。像

    var ref = new Firebase("myfirebase");
    ref.orderByChild("department").endAt("xyz").on("child_added", function(snapshot) {
    console.log(snapshot.key());
    });
    

    应该这样做。

    【讨论】:

    • 我自己从来没有在IOS中做过,但我想应该差不多,检查这里:firebase.com/docs/ios/guide/…
    • 几乎一样。并且在文档中得到了很好的介绍。请注意,在这种情况下,equalTo(iOS 中为 queryEqualToValue)比 endAt 更可取,因为我们正在模拟 where x = y
    猜你喜欢
    • 2018-06-02
    • 2021-08-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-05-05
    • 2017-09-03
    • 1970-01-01
    • 2022-06-12
    相关资源
    最近更新 更多