aggregate with date filter mongo db

Haritha


return await this.orderHistoryModel.aggregate([
{ $match: { createdAt: { $gt: new Date('2023-08-05') } } }
]);
const totals = await this.penaltyConsumptionLogsModel.aggregate([
{ $match: { createdAt: { $gte: new Date('2023-08-05'), $lte: new Date('2023-08-05') } } },
{ $group: { _id: null, totalBeforePenalty: { $sum: '$beforePenalty' }, totalAfterPenalty: { $sum: '$afterPenalty' }, totalAdjustedAmount: { $sum: '$adjustedAmount' } } }
]).exec();