【发布时间】:2016-12-02 00:35:43
【问题描述】:
我正在尝试计算每月的平均航班,但我收到一个错误
"一个流水线阶段规范对象必须只包含一个字段。",
db.Flights.aggregate([
{$unwind: "$flights"},
{$project:
{_id: 0,
status: 1,
flights: 1
},
$match: {"status": "active"},
$group: {_id: {"flights" : "$flights.flight_id", "Month": "$depart_info.month_name_long"},
avg_flights: {$avg: "$flights.count"}}}
])
【问题讨论】:
标签: mongodb match aggregation-framework