jeudi 29 septembre 2016

How to retrieve an object ID generated by firebase

I have the following object:

root: {
  id1: { /* this is an autogenerated id by Firebase */
    name1: "abc",
    name2: "xyz"
  },
  id2: {
    name1: "abc",
    name2: "xyz"
  },
  id3: {
    name1: "abc",
    name2: "xyz"
  },
}

My code to retrieve the whole snapshot is:

getRoot () {
    firebase.database ().ref ('roots/')
      .on('value', function (snapshot) {
        console.log (snapshot.val());
      })
  }

Everything is perfect. I got the whole root object, but I can't figure out how to access the IDs and their children.

Thanks!




Aucun commentaire:

Enregistrer un commentaire