title: How to read Firebase Database entry in Firebase Cloud Functions' index.js?
body: <p>I am trying to create device to device push notifications for an iOS app using Firebase Cloud functions. I want to trigger an event whenever a new child is created in database at reference '/user-notifications/{notificationRecipientUid}/{challengeId}'. Here is my index.js code:</p>
  
  <pre><code>const functions = require('firebase-functions');
  const admin = require('firebase-admin');
  admin.initializeApp(functions.config().firebase);
  
  exports.sendWinLoseOrTieNotification = functions.database.ref('/user-notifications/{notificationRecipientUid}/{challengeId}').onWrite(event =&gt; {
  ...
  const challengeId = event.params.challengeId;
  
  functions.database.ref('/challenges/' + challengeId).once('value').then(function(snapshot) {
      const challengerUid = snapshot.val().challengerUid;
      ...
  });
  });
  </code></pre>
  
  <p>When a new child is added in the database at that location, I get this error, "TypeError: functions.database.ref(...).once is not a function", in Firebase Console's Functions Logs. So there is no 'once' method available
   on ref like in web api:</p>
  
  <p><code>firebase.database().ref('...').once('value').then(function(snapshot) {
    ...
  });</code></p>
  
  <p>My question is: How to read an existing database value inside index.js?</p>