公司工作地点:上海市发布时间:2009-7-11
db.xxx.find({ "$where“:function() { return 'UserDtls.dob'.getMonth() == 8}})
我需要上面这样的东西。
发布于 2018-07-25 17:39:34
这可以正常工作,$expr
db.collection.find({ "$expr": { "$eq": [{ "$month": "$UserDtls.dob" }, 7] } })它只返回7个月的数据,MongoDB 3.6运行良好
或
db.collection.aggregate([
{$project: {month: {$month: '$UserDtls.dob'}}},
{$match: {month: 7}}
]);https://stackoverflow.com/questions/51515227
复制相似问题