Firebase javascript question? ok to post here?

in firebase if you use push , it generates a key. Now, if push several items there will be several keys. If each item has for example name as a property. lets say I push name: john twice. Now I will have two unique keys but both will contain name: john.

  playersRef.push({
    name:  "john"
    interest: "hockey",
  });

everything I have read says you can access the data using something like below, but i want to access it by the individual key so I know I access the correct “john”, any suggestions?

  playersRef.on("value", function (snapshot) {
    snapshot.forEach(function (childSnapshot) {
      let data = childSnapshot.val().name;

      if ((data = "john")) {
        console.log(data);
      }
    });
  });

I don’t know firebase, but I imagine that here you want to compare not to assign

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.