MongoDB - orderby语法中断语句

时间:2017-11-09 02:27:30

标签: mongodb mongodb-query

以下查询一直有效,直到我添加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}}


])

有人可以帮忙吗?

0 个答案:

没有答案