Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/mongodb/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Mongodb 此对象已经是运算符表达式,并且可以';不能用作文档表达式_Mongodb - Fatal编程技术网

Mongodb 此对象已经是运算符表达式,并且可以';不能用作文档表达式

Mongodb 此对象已经是运算符表达式,并且可以';不能用作文档表达式,mongodb,Mongodb,在mongodb中执行以下命令时出错: db.trans.aggregate( [ { $match: {"cno":89}}, { $group: { _id: [ $dateToString: { format: "%Y-%m-%d", date: "$transactiondate" },types:"$type"], count: { $sum: 1 } } }]) 我想按交易日期和类型分组 错误是: assert: command failed: { "ok"

在mongodb中执行以下命令时出错:

db.trans.aggregate(
   [
  { $match: {"cno":89}},
  { $group: { _id: [ $dateToString: { format: "%Y-%m-%d", date: "$transactiondate" },types:"$type"], count: { $sum: 1 } } }])
我想按交易日期和类型分组

错误是:

assert: command failed: {
    "ok" : 0,
    "errmsg" : "this object is already an operator expression, and can't be used as a document expression (at 'types')",
    "code" : 15990
} : aggregate failed_getErrorWithCode@src/mongo/shell/utils.js:25:13
doassert@src/mongo/shell/assert.js:16:14
assert.commandWorked@src/mongo/shell/assert.js:370:5
DBCollection.prototype.aggregate@src/mongo/shell/collection.js:1319:5
@(shell):1:1

2017-10-24T15:38:35.498+0530 E QUERY    [thread1] Error: command failed: {
    "ok" : 0,
    "errmsg" : "this object is already an operator expression, and can't be used as a document expression (at 'types')",
    "code" : 15990
} : aggregate failed :
_getErrorWithCode@src/mongo/shell/utils.js:25:13
doassert@src/mongo/shell/assert.js:16:14
assert.commandWorked@src/mongo/shell/assert.js:370:5
DBCollection.prototype.aggregate@src/mongo/shell/collection.js:1319:5
@(shell):1:1
{$group:{{u id:{“date”:{$dateToString:{格式:'%Y-%m-%d',日期:$transactiondate'}},类型:$type'},计数:{$sum:1}}
。几个基本语法错误。如果你只是把改正的地方和你做错的地方进行比较,那就容易多了。