如何根据节点中的特定值从firebase获取数据

时间:2015-02-18 05:13:19

标签: ios firebase firebase-realtime-database

我的firebase数据库如下所示

projectmasternode

|

 -DS

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

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

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

现在如何获取department =“xyz”的部门数据。

1 个答案:

答案 0 :(得分:3)

您的答案在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());
});

应该这样做。