【发布时间】:2016-04-13 06:07:40
【问题描述】:
mongodb的示例文档:
{
"_id" : ObjectId("512eef329d5d0c9415000025"),
"time" : NumberLong(1431973102)
}
我想从聚合查询中保存在时间属性中的时间戳值中获取 $dayOfMonth,但我有这个异常消息:
uncaught exception: aggreate failed: {
"errmsg" : "exception: can't convert from BSON type NumberLong64 to Date",
"code" : 16006,
"ok" : 0
}
当我运行这个查询时:
db.getCollection('collection_name').aggregate([
{ $match: { '_id': ObjectId('512eef329d5d0c9415000025') } },
{ $project: { 'time': 1, "dayOfMonth": { $dayOfMonth: '$time' } } }
])
有什么想法吗?谢谢。
【问题讨论】:
标签: mongodb aggregation-framework