search

Home  >  Q&A  >  body text

node.js - mongodb怎么对分组,不要统计

mongo.getCollection('t_app').aggregate([
        {
            $group: {
                _id: {
                    FuncName: "$FuncName",
                    Platform: "$Platform",
                    UseDateTime:{  $dateToString: { format: "%Y-%m-%d", date: "$UseDateTime" }}
                }
            }
        }
    ]

上面只是一个构想。。。,我想根据这些key的字段要求,进行分组,,不需要统计,完整的应该怎么写?

PHPzPHPz2781 days ago587

reply all(1)I'll reply

  • 阿神

    阿神2017-04-17 15:34:02

    $push

    Just push the result into the array.

    mongo.getCollection('t_app').aggregate([
            {
                $group: {
                    _id: {
                        FuncName: "$FuncName",
                        Platform: "$Platform",
                        UseDateTime:{  $dateToString: { format: "%Y-%m-%d", date: "$UseDateTime" }}
                    },
                    result : {$push : "$Platform"}
                }
            }
        ]

    reply
    0
  • Cancelreply