I am trying to use $gte in aggregation based on property from aggregation in Nodejs.
const twelveHours = 12 * 60 * 60 * 1000;
const pipeline = [
{ $addFields: {
twelveHoursBeforeStart: { $subtract: ['$startDate', twelveHours] } } // this works
},
{ match: {
endDate: { $gte: new Date('$twelveHoursBeforeStart') }, // <- HERE pass a variable
},
]
I have tried different solutions like:
{ match: {
endDate: { $gte: '$twelveHoursBeforeStart' },
},
but non of them actually works