Sending Related Data from Multiple Collections with MongoDB Trigger

I’m using a webhook to trigger an action whenever there’s an insert in my MongoDB. I have two collections and I want to send data from both collections using the webhook. Currently, I can only select one collection in MongoDB trigger. The collections have a reference field that links the documents together. I want to send the related data from the second collection when new data is inserted into the first collection. I’ve tried modifying the code, but I’m facing issues with the result. Can anyone provide guidance on how to modify the code to achieve this requirement?

Here’s my code:

exports = function(changeEvent) {
  const fullDocument = changeEvent.fullDocument;
  const webhookUrl = 'https://abcde.m.pipedream.net';

  const http = context.http;

  const energyCalculationResultId = fullDocument._id;
  const energyItemCollection = context.services.get("mongodb-atlas").db("mydb").collection("EnergyItem");
  
  const energyItems = energyItemCollection.find({ energyCalculationResultId: energyCalculationResultId }).toArray();
  
  const dataToSend = {
    EnergyResult: fullDocument,
    EnergyItems: energyItems
  };

  http.post({ url: webhookUrl, body: dataToSend, encodeBodyAsJSON: true })
    .then(response => {
      console.log(`Sent data to ${webhookUrl}`);
    })
    .catch(error => {
      console.error(`Failed to send data to ${webhookUrl}:`, error);
    });
};