mongodb鐨勪竴浜涙煡璇

鍒嗙粍骞朵繚鐣欏叾浣欑殑瀛楁

db.getCollection("facebook_ad_insight").aggregate([{
    $match: {
        "date_start": {
            $gt: "2020-11-02",
                        $lt: "2020-11-16"
        }
    }
}, {
    $group: {
                _id: {
                adset_id    :"$account_id"
                },
                "doc": { "$first": "$$ROOT" }
    }
},
{ "$replaceRoot": { "newRoot": "$doc" }}
])

鍒嗙粍姹囨诲姞鎺掑簭

db.getCollection("facebook_ad_insight").aggregate([{
    $match: {
        "date_start": {
            $gt: "2020-11-02"
        }
    }
}, {
    $group: {
                _id: {
                date_start:"$date_start",
              adset_id  :"adset_id"
                },
        spend: {
            $sum: { $toDouble: "$spend" }
        }
    },
    },  {$sort:{"_id.date_start":1}}
])

All posts

Other pages

鍙戣〃璇勮

閭鍦板潃涓嶄細琚叕寮銆 蹇呭~椤瑰凡鐢*鏍囨敞