title: How to set a listener on Firebase value event?
body: <p>How to properly set up a value event listener with Firebase, using Node.js?</p>
  
  <p>I'm reading through <a href="https://firebase.google.com/docs/database/web/read-and-write" rel="noreferrer">Firebase's documents</a>, <strong>and have successfully been able to update tables and rows on my Firebase database</strong> from both my Mac, and my Raspberry Pi running at the same time, connected to the same Firebase database; however, I'm not able to understand what I need to do with this segment for making a listener on a value event:</p>
  
  <pre><code>var starCountRef = firebase.database().ref('posts/' + postId + '/starCount');
  starCountRef.on('value', function(snapshot) {
      updateStarCount(postElement, snapshot.val());
  });
  </code></pre>
  
  <p>It's <strong>evident</strong> to me that I need somehow need to define <code>postElement</code> based on the output: </p>
  
  <pre><code>FIREBASE WARNING: Exception was thrown by user callback. ReferenceError: postElement is not defined
  </code></pre>
  
  <p><em>However, I have not idea what <code>postElement</code> is supposed to be, nor how to define it. Help!</em></p>
  
  <p>I've made a very small program and table to simply update/change values. And I changed the program to I can see up console output when a row it changed.</p>
  
  <p>This is my small user data variable, just so you now how little data I'm trying to change:</p>
  
  <pre><code>var user = {
      id:Number,
      name:String,
      number:Number
  };
  
  var users = [user];
  </code></pre>
  
  <p>And this is my change to the documentation code, so I can see something in the console output while Node.js is running:</p>
  
  <pre><code>var userRef = firebase.database().ref('/users/user' + users[0].id);
  userRef.on('value', function(snapshot){
      firebase.app.updateUserInfo(postElement, snapshot.val());
      console.log('Users' + users[0].name + ' changed.');//&lt;- this is the line I added.
  });
  </code></pre>
  
  <p>NOTE: <code>updateStarCount</code> function is from the example in the Firebase documentation, meaningful to the example there, which I cautiously assume updates the local Firebase db... </p>
  
  <p>NOTE2: If <code>updateStarCount</code> is doing some other magic, then it is a documentation flaw with Firebase, because the function isn't defined there. Any help clarifying this documentation would be greatly appreciated.</p>