如果要通过其他方式解决此问题,请让我知道
我尝试了以下汇总方法:
db.CLV_MATERIAL_AGING.aggregate([ { $match: {"Material_Number" :
"000000000810000010"}},
{
$group: {
_id: 'null',
total:{
$sum:{$convert: {'input': '$MR', 'to': 'double'}}
},
count:{
$sum:1
}
}
}])
给我错误:-
{
"message" : "Unrecognized expression '$convert'",
"stack" : "MongoError: Unrecognized expression '$convert'" +
"at queryCallback
(/tmp/.mount_nosqlbn5xIBs/app/resources/app.asar/node_modules/mongodb-
core/lib/cursor.js:247:25)" +
"at
/tmp/.mount_nosqlbn5xIBs/app/resources/app.asar/node_modules/mongodb-
core/lib/connection/pool.js:531:18" +
"at _combinedTickCallback (internal/process/next_tick.js:131:7)" +
"at process._tickCallback (internal/process/next_tick.js:180:9)",
"name" : "MongoError",
"ok" : 0,
"errmsg" : "Unrecognized expression '$convert'",
"code" : 168,
"codeName" : "InvalidPipelineOperator"
}
并且$toDouble()
在mongoDB v3.6.5中不可用我已经在mongodb v4中进行了尝试,但是在mongodb v3.5.6中没有使用