I want to filtre data using $match
and group it using $group
since I use dynamic variable in $match stage I got no result,
let logs = await Promise.all(
tpes.map(async (item) => {
return await this.logModel.aggregate([
{ $match: { terminalId: item } },
{
$group: {
_id: '$outcome',
value: {
$sum: 1,
},
},
},
{
$project: {
name: '$_id',
value: 1,
_id: 0,
},
},
]);
}),
);
console.log('logs', logs);
logs here is an array contain ids from where I want to get data