let logs = await Promise.all(
tpes.map(async (item) => {
console.log(item);
for (let index = 0; index <= item.length; index++) {
return await this.logModel.aggregate([
//find({ terminalId: item }).model.
{ $match: { terminalId: item[index] } },
{
$group: {
_id: '$outcome',
value: {
$sum: 1,
},
},
},
{
$project: {
name: '$_id',
value: 1,
_id: 0,
},
},
]);
}
}),
);
console.log('logs', logs);
return logs.flat();
I want to match data with specific Id each time
NB: item = [‘id1’,‘id2’]
I just got the first iteration means it matchs the id1 and it stops any solution or alternative to have loop through the array and get all matchs ?
I know that I can use find() method but i need the aggregation to make group by and sum after the opertation
