title: How to get a new database reference inside an onCreate function for sending mail?
body: <p>I'm creating a function to send mail whenever a new order is being placed and I want to get a reference to the user email which is inside the database whose path is => Users/uid/email to get the email id of the user to send the mail. How to get this reference inside my function?</p>
  
  <p>I've tried firebase.database.ref(<code>/Users/${userId}/email</code>).val(), admin.database.ref(<code>/Users/${userId}/email</code>).val(). But none of these work.</p>
  
  <pre><code>exports.orderPlaced = functions.database.ref(/Users/{uid}/Bag/Books/{orderId}).onCreate((snapshot, context) =&gt; {
  
  
  const userId = context.params.uid;
  const orderid = context.params.orderId;
  
  const refer = firebase.database.ref(/Users/${userId}/email).val();
  
  const mailOptions = {
      from: '"abc" &lt;abc@gmail.com&gt;',
      to: 'xyz@gmail.com',
      subject: 'Order Details',
      html: `&lt;p style="font-size: 16px;"&gt;${orderId}&lt;/p&gt;
              &lt;br /&gt;
          ` // email content in HTML
  };
  
  try {
      mailTransport.sendMail(mailOptions);
      console.log('mail send');
  
  } 
  catch(error) {
      console.error('There was an error while sending the email:', error);
  }
  
  return null; 
  });
  </code></pre>
  
  <p>I want to get the email id of the user but I get the error that firebase is not defined at exports.orderPlaced.functions.database.ref</p>