以下查询一直有效,直到我添加orderby语句,但是当我尝试在添加它之后运行时会抛出异常
db.games.aggregate([
{$unwind: "$games"},
{$project: {_id: 0, year: {$substr: ["$join_date", 0, 4]},
status: 1,
games: 1}},
{$match: {status: {$ne: "disabled"}}},
{$group: {_id: {"Year": "$year", code: "$games.code"}, "AverageWins": {$avg: "$games.wins"}}},
{$orderby: {"AverageWins": -1}}
])
有人可以帮忙吗?