title: Firebase count num children of parent
body: <p>I'm trying to get the number of children for a parent node in js firebase.
  I'd like to have:</p>
  
  <pre><code>'user': {
      '-Yuna99s993m': { count: 1},
      '-Yada99s993m': { count: 2},
  }
  </code></pre>
  
  <p>I'm creating a cloud function witch every time a new node is entered it should add count equal to numChildren of user node.</p>
  
  <pre><code>exports.setCount = functions.database.ref('/user/{userId}').onWrite(event =&gt; {
      // This doesn't work
      const count = event.data.ref.parent.numChildren();
      return event.data.ref.update({ count });
  });
  </code></pre>
  
  <p>Any help to get this working?</p>
  
  <p>Thank you.</p>