db.foo.aggregate({$project:{dateToString:{$substr:["$d",0,4]},_id:0}})
|
{ "dateToString" : "2017" }
|
db.foo.aggregate({$project:{dateToString:{$toUpper:"$d"},_id:0}})
|
{ "dateToString" : "2017-08-01T17:29:05" }
|
db.foo.aggregate({$project:{dateToString:{$toLower:"$d"},_id:0}})
|
{ "dateToString" : "2017-08-01t17:29:05" }
|
db.foo.aggregate({$project:{dateToString:{$concat:["$d","_"]},_id:0}})
|
assert: command failed: {
|
"ok" : 0,
|
"errmsg" : "$concat only supports strings, not date",
|
"code" : 16702,
|
"codeName" : "Location16702",
|
"$clusterTime" : {
|
"clusterTime" : Timestamp(1501608545, 1),
|
"signature" : {
|
"hash" : BinData(0,"y9mqIQNK2OhW40Hm2VIctAxrgcQ="),
|
"keyId" : NumberLong("6448521287567409154")
|
}
|
},
|
"operationTime" : Timestamp(1501608545, 1)
|
} : 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:403:5
|
DB.prototype._runAggregate@src/mongo/shell/db.js:250:9
|
DBCollection.prototype.aggregate@src/mongo/shell/collection.js:1269:12
|
@(shell):1:1
|
|
2017-08-01T10:48:52.841-0700 E QUERY [thread1] Error: command failed: {
|
"ok" : 0,
|
"errmsg" : "$concat only supports strings, not date",
|
"code" : 16702,
|
"codeName" : "Location16702",
|
"$clusterTime" : {
|
"clusterTime" : Timestamp(1501608545, 1),
|
"signature" : {
|
"hash" : BinData(0,"y9mqIQNK2OhW40Hm2VIctAxrgcQ="),
|
"keyId" : NumberLong("6448521287567409154")
|
}
|
},
|
"operationTime" : Timestamp(1501608545, 1)
|
} : 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:403:5
|
DB.prototype._runAggregate@src/mongo/shell/db.js:250:9
|
DBCollection.prototype.aggregate@src/mongo/shell/collection.js:1269:12
|
@(shell):1:1
|