MongoError”,消息:“无法从缺少的BSON类型转换为日期

时间:2019-02-15 11:56:36

标签: mongodb-query

显示mongo错误代码16006

Windows节点服务器

我的模型在这里: 项目:{

fundingInfo : [
  {
    investAmount : Number,
    investDate : Date
  }
]

and query is:
Projects.aggregate(
    {
        $project:{
            year:{$year:"$fundingInfo.investDate"},
            month:{$month:"$fundingInfo.investDate"},
            "fundingInfo" : 1,
            "_id" : 1
        }
    },
    {
        $unwind:"$fundingInfo"
    }, 
    { 
        $match : 
        {
            "_id": new mongoose.Types.ObjectId(projectRefId),
            "year" : new Date().getFullYear()
        }
    },
    {
        $group : {
            _id   : {year : "$year", month : "$month"}, 
            total : {$sum : "$fundingInfo.investAmount"}
        }
    }
....

在执行时,显示错误: MongoError”,消息:“无法从缺少的BSON类型转换为日期”,确定:0,…} 代码:16006

0 个答案:

没有答案