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


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM