MongoDB异常解析

时间:2017-06-19 08:25:55

标签: mongodb

这是我在MongoDB中的收藏

db.time.entries.findOne({"userId" : "k89L3cLE3pEu3Tn2Y"})
{
    "_id" : "eQ9KpemZCSPBzKi7W",
    "createdAt" : ISODate("2016-04-03T21:00:00Z"),
    "userId" : "k89L3cLE3pEu3Tn2Y",
    "duration" : 2700,
    "metadata" : {
            "patientId" : "37253xjB4orjSKPK7",
            "manual" : true,
            "organizationId" : "gb8gbhvhqgYc6x3nK",
            "careManagementType" : "CCM"
    }

}

当我运行以下查询时,我收到以下错误

db.time.entries.aggregate([{$match: {userId: "k89L3cLE3pEu3Tn2Y"}}, 
{ $group : { _id :{ "day" : {"$dayOfYear" : "$createdAt"}, "year": { "$year" : "$createdAt"}}, count: {$sum:"$duration"}}} ])


assert: command failed: {
    "ok" : 0,
    "errmsg" : "can't convert from BSON type EOO to Date",
    "code" : 16006
} : 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:290:5
DBCollection.prototype.aggregate@src/mongo/shell/collection.js:1312:5
@(shell):1:1

你能帮我解决一下这个问题。我有一个用于创建列的ISODate,但我仍然收到此错误。

0 个答案:

没有答案