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}}
);