title: using two or more realtime query in one export function in firebase
body: <p>Is there any way I can use two realtime database queries in one export function?</p>
  
  <p>When I run this it works without errors:</p>
  
  <pre><code>exports.testDbOp = functions.https.onRequest((req, res) =&gt; {
  
      var totalKeys = 7;
  
      return admin.database()
          .ref('/messages')
          .orderByChild('id')
          .startAt(2)
          .limitToFirst(2)
          .once('value')
          .then(snap =&gt; { res.status(200).json({ total: totalKeys, date: snap.val() })
              return 1
          })
      .catch(e =&gt; console.error(e));
  });
  </code></pre>
  
  <p>but when I try to add the other query, it will trigger warnings on the CLI and it wouldn't show the total rows</p>
  
  <pre><code>exports.testDbOp = functions.https.onRequest((req, res) =&gt; {
      var db = admin.database();
      var ref = db.ref("/messages");
      ref.on("value", snapshot =&gt;  { 
          var totalKeys = snapshot.numChildren(); }, 
          function (errorObject) {
              console.log("The read failed: " + errorObject.code);
      });
  
      return admin.database()
          .ref('/messages')
          .orderByChild('id')
          .startAt(2)
          .limitToFirst(2)
          .once('value')
          .then(snap =&gt; { res.status(200).json({ total: totalKeys, datas: snap.val() })
              return 1
          })
      .catch(e =&gt; console.error(e));
  });
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/jSuxl.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/jSuxl.png" alt="enter image description here"></a></p>
  
  <p>This is what I did about, I'm trying to get the total messages key and pass it into json data but it did't work </p>