lookup aggregation takes; time : 1174ms with size : 62.95kb is that normal ??
Here is my function below
if (role === ROLEV1.MS_TECH_SOFT) {
let logs = await this.profileModel.aggregate([
{
$match: {
bindedSuperAdmin: name,
},
},
{
$lookup: {
from: 'tpes',
localField: 'nameUser',
foreignField: 'merchantName',
as: 'tpesBySite',
},
},
{
$lookup: {
from: 'logs',
localField: 'tpesBySite.terminalId',
foreignField: 'terminalId',
as: 'logsByTpes',
pipeline: [
{
$sort: {
transactionDate: -1,
// transactionDate: { $in: [startDate, endDate] },
},
},
],
},
},
{ $unwind: '$tpesBySite' },
{ $unwind: '$logsByTpes' },
{
$project: {
// bindedSuperAdmin: '$bindedSuperAdmin',
// bindedBanque: '$bindedBanque',
// bindedClient: '$bindedClient',
uniqueID: '$logsByTpes.uniqueID',
sn: '$logsByTpes.sn',
terminalId: '$logsByTpes.terminalId',
transactionAmount: '$logsByTpes.transactionAmount',
currencyCode: '$logsByTpes.currencyCode',
transactionDate: '$logsByTpes.transactionDate',
transactionTime: '$logsByTpes.transactionTime',
transactionType: '$logsByTpes.transactionType',
cardPAN_PCI: '$logsByTpes.cardPAN_PCI',
onlineRetrievalReferenceNumber:
'$logsByTpes.onlineRetrievalReferenceNumber',
outcome: '$logsByTpes.outcome',
},
},
]);
console.log(logs.length, ' length from ms prfile service');
return logs;
}
Does this query could be better ? any help please