简体   繁体   中英

how to fetch data from firebase based on particular value in a node

i have firebase data base as below

projectmasternode

|

 -DS

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

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

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

now how to get departments data where department= "xyz".

Your answer is right in the FB docs. Check here : https://www.firebase.com/docs/web/guide/retrieving-data.html#section-queries and take a look at orderByChild combined with another filter, like endAt. Something like

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

Should do it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM