【发布时间】:2019-09-28 03:28:33
【问题描述】:
我想在数组对象内的数据上聚合 $match:
{ example: [{target: "1"}] }
我试过$match、$elemMatch、$arrayEleAt,但我不知道如何写出正确的语法。
{ $lookup: { from: "example", localField: "user_id", foreignField: "user_id", as: "example" } },
{
$match: {
"start_date": { $gte: new Date(startDate) },
"end_date": { $lte: new Date(endDate) },
"type": Type,
"target": "1"
},
},
{ $sort: { startDate: 1 } },
【问题讨论】:
标签: mongodb mongoose aggregate aggregate-functions