Answers for "firebase get child value javascript"

0

firebase get child value javascript

The value you extract is a regular JavaScript/JSON object,
so you can access its members as you would do with any other JavaScript object.
Your 1, 2, 3 level keys will be converted to an array by Firebase,
which means it adds a null item at the start of that array.
For more about that, see: Firebase database returns null at beginning of each new node

To loop over all child nodes under the child of patterns that was changed and get the players whose status is 0 you'd do something like:

var ref = firebase.database().ref("games/" + gameId + "/patterns");
ref.on("child_changed", function(snapshot){
  snapshot.forEach(function(child) {
    if (child.val() && child.val().status == "0") {
      console.log(child.val().player);
    });
  });
});
Posted by: Guest on June-28-2021

Code answers related to "firebase get child value javascript"

Code answers related to "Javascript"

Browse Popular Code Answers by Language