MongoDB按条件查找并求和

https://blog.csdn.net/AaronDev/article/details/103858939

db.getCollection("cal1.files")
.aggregate({
    $match:{
        $and:[
            {uploadDate:{$gte:ISODate("2019-12-30T00:00:00.303Z")}},
            {uploadDate:{$lte:ISODate("2020-01-05T00:00:00.303Z")}},
        ]
    }
},
{
    $group: { _id : null, sum : { $sum: "$length" } } 
})

 

posted @ 2021-02-05 10:23  码农骆驼  阅读(1503)  评论(0编辑  收藏  举报