title: how to join two separate table(not child table ) in firebase using id?
body: <p>I am new in firebase Environment .I have firebase database as follows </p>
  
  <p><a href="https://i.stack.imgur.com/WlneC.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/WlneC.png" alt="image of two firebase table "></a></p>
  
  <p>I have two firebase table named as customer and booking where i want to do join operation using cloud function. In the booking table there is row named as <strong>customerId</strong> which corresponds to the <strong>uid</strong> of customer table. I want to do a join operation between them and show the joined table. Any help is appreciated 
   I have tried the following code:</p>
  
  <pre><code>exports.join = functions.https.onRequest((request, response) =&gt; {
          response.header('Content-Type', 'application/json');
          response.header('Access-Control-Allow-Origin', '*');
          response.header('Access-Control-Allow-Headers', 'Content-Type');
            if (request.method === 'OPTIONS') {
           response.status(204).send('');
         }
      var booking=admin.database().ref().child('booking');
      var customer=admin.database().ref().child('booking');
  
      booking.on('child_added',function(snap){
      console.log(snap.val());
  
      customer.child(snap.val().uid).once('value',user =&gt;{
      console.log(user.val());
  
     response.status(200).json({ booking: snap.val(),customer: user.val() });
  
      });
     // response.status(200).json({ order: snap.val(),user: user.val() });
  
      });
  
  });
  </code></pre>
  
  <hr>
  
  <p>I modified the above code . and write the function as follows:</p>
  
  <pre><code>exports.join2 = functions.https.onRequest((req, res) =&gt; {
      res.header('Content-Type', 'application/json');
      res.header('Access-Control-Allow-Origin', '*');
      res.header('Access-Control-Allow-Headers', 'Content-Type');
  
      //respond to CORS preflight requests
      if (req.method === 'OPTIONS') {
          res.status(204).send('');
      }
      var booking = admin.database().ref().child('booking');
      var customer = admin.database().ref().child('customer');
  
      customer.on('child_added', function (snap) {
          var uid = snap.val().uid; // line 1 (results like 1,2,3,4,5,6)
          console.log(uid);
  
  
          booking.orderByChild('customerId').equalTo(uid).on('value', function (snapshot) {
              // customer.orderByChild('uid').equalTo(userId).once('value', function(snapshot) {
              console.log(uid + "--------------------------------------&gt;");
              console.log(snapshot.val());
              res.status(200).json({ customer: snap.val(), booking: snapshot.val() });
  
          });
      });
  });
  </code></pre>
  
  <p>The data returning in the console is fine but when I returned the response as json object it only return first object that is first customer along with their  booking details and I am unable to return as all customer data with their booking.
  Any suggestion .</p>