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