尝试使用以下查询按日期聚合但未获得结果

时间:2017-01-23 15:38:02

标签: mongodb date group-by aggregation-framework

db.track_visits_y17_m01.aggregate([{
    $match: {
        "trackingData.gradeId": {
            $in: ["12", "15", "16", 12, 15, 16]
        },
        "created": {
            $gte: "2017-01-01 00:00:00",
            $lt: "2017-01-23 00:00:00"
        }
    }
}, {
    $group: {
        _id: {
            year: {
                $year: "$created"
            },
            month: {
                $month: "$created"
            },
            day: {
                $dayOfMonth: "$created"
            },
        },
        total: {
            $sum: 1
        }
    }
}])

它会运行但不会返回任何内容。

0 个答案:

没有答案