2

I'm a newbie working on an Android project using Firebase v3.

I have set up a data structure that relates stores to brands as follows:

stores -> [brandId] -> [storeId] -> store object

"stores" : {
  "1z05cQF7FnWkCTe2KC9eqCHi6Ji2" : {
    "hSlKozrMq2aNGQqWDZ7eU2UzNtr1" : {
      "brid" : "1z05cQF7FnWkCTe2KC9eqCHi6Ji2",
      "email" : "di@cof.ci",
      "uid" : "hSlKozrMq2aNGQqWDZ7eU2UzNtr1"
    }
  },
  "LqZ81PF7bKXPtoASWUWMQKFYMK62" : {
    "-Kidnq4rlssa5d1Ic8gv" : {
      "brid" : "LqZ81PF7bKXPtoASWUWMQKFYMK62",
      "email" : "test@test.test",
      "uid" : "-Kidnq4rlssa5d1Ic8gv"
    }
  },
}

I would like without knowing the brandId to get the store object. Is that possible?

I tried using orderByChild and orderByKey but nothing seems to work, either everything is returned or null. e.g.

var tellerRef = firebase.database().ref('/stores/');
tellerRef.orderByChild(uid).once('value').then((snapshot) => console.log(snapshot.val()));

where uid = "hSlKozrMq2aNGQqWDZ7eU2UzNtr1" returns everything!

AL.
  • 36,815
  • 10
  • 142
  • 281
  • I have a similar question: I want to filter by user where Rooms/[roomKey]/Users/[userkey] – Sean Jul 29 '17 at 06:13

0 Answers0