Untitled
unknown
plain_text
4 years ago
484 B
7
Indexable
async created() {
try {
const startOfThisMonth = moment().startOf('month').toDate();
const pipeline = [
{
$match: {
status: { $ne: 'cancelled' },
createdAt: { $gte: startOfThisMonth },
},
},
{
$group: {
_id: null,
grand: { $sum: '$grandTotal' },
},
},
];
const res = await this.adapter.model.aggregate(pipeline);
console.log(res);
console.log(res.length);
} catch (err) {
console.log(err);
}
},Editor is loading...