Mongodb exception: A pipeline stage specification object must contain exactly one field

 

assert: command failed: {
"errmsg" : "exception: A pipeline stage specification object must contain exactly one field.",
"code" : 16435,
"ok" : 0
} : aggregate failed
Error: command failed: {
"errmsg" : "exception: A pipeline stage specification object must contain exactly one field.",
"code" : 16435,
"ok" : 0
} : aggregate failed
at Error ()
at doassert (src/mongo/shell/assert.js:11:14)
at Function.assert.commandWorked (src/mongo/shell/assert.js:244:5)
at DBCollection.aggregate (src/mongo/shell/collection.js:1149:12)
at (shell):1:10
2014-11-13T10:55:38.677+0000 Error: command failed: {
"errmsg" : "exception: A pipeline stage specification object must contain exactly one field.",
"code" : 16435,
"ok" : 0
} : aggregate failed at src/mongo/shell/assert.js:13

db.orders.aggregate({
$group: { _id: "$idClient",countCli: { $sum: 1}},
$sort:{countCli:1}
});

To solve the problem change the request as follows

db.orders.aggregate(
{$group: { _id: "$idClient",countCli: { $sum: 1}}},
{$sort:{countCli:1}}
);

posted @ 2017-07-07 13:44  天涯逐梦  阅读(7882)  评论(1)    收藏  举报