我无法获取aggregate
查询中两个日期之间创建的对象数。以下是我的汇总查询与指定的project
相似的内容。
DataTable.aggregate([
{ $match: { ... } },
{ $lookup: { ... },
{ $project: { ... },
{ $match: { ... },
{
$project: {
count: {$sum: {'$cond': [{ '$gte': ['date', '$someOldDate'], '$lte': ['date', someNewDate] }, 1, 0]} }
}
}
])
以下是Mongoose
MongoError: An object representing an expression must have exactly one field: { $gte: [ "date", "$someOldDate" ], $lte: [ "date", new Date(1496772810338) ] }