Pipeline: accessing variables defined in $let

Hello!

Is there a way to output the actual values of the variables defined in the “$let” stage of a lookup? For debug purposes, I mean.

In something like
$lookup{…
let: {source: “SOURCE”, joinKey: “$CONC_DN”, dataType: “EVALS”, endDate: {$add: [{$toDate:"$SCHEDULEDDATE"}, -(31000606024)]}},

I would like to see whether endDate is actually correct (3 days before the value of SCHEDULEDDATE)

Thank you in advance!

Here is an example of how you can debug your custom vars inside $lookup.pipeline:

const pipeline = [
  {
    $lookup: {
      from: 'other_collection',
      let: {
        varA: '$parentProp',
      },
      pipeline: [
        {
          // this is needed to output only 1 doc with vars
          // and hide all the unnecessary fields
          $group: {
            _id: null,
          },
        },
        {
          $addFields: {
            debugVarA: '$$varA',
          },
        },
      ],
      as: 'result',
    },
  },
];