exception: can't convert from BSON type EOO to Date

前端 未结 8 1299
情歌与酒
情歌与酒 2020-11-28 10:26

I am getting an issue for running the following aggregate query:

db.snippets.aggregate([ { \'$project\': { month: { \'$month\': \'$created_at\' }} } ])
         


        
8条回答
  •  无人及你
    2020-11-28 10:55

    I had a similar problem, and solved it checking if the date existed.

    db.users.aggregate([
    {$project:{day:  { $cond: ["$bd", { $dayOfMonth: "$bd" }, -1] },
               month:  { $cond: ["$bd", { $month: "$bd" }, -1] },
               year:  { $cond: ["$bd", { $year: "$bd" }, -1] }
               }},
    {$match:{"month":1, "day":15}}
    ])
    

    My date field is bd and with that match I'm getting all users that have their birthday on January 15th.

提交回复
热议问题