MongDB aggregation _ sample

[{
 $match: {
  createdTime: {
   $gt: ISODate('2022-08-23T00:00:00.000Z')
  }
 }
}, {
 $match: {
  invalidType: {
   $ne: 'InvalidUser'
  }
 }
}, {
 $match: {
  $and: [
   {
    message: {
     $ne: 'succed'
    }
   },
   {
    retryNeeded: {
     $ne: false
    }
   }
  ]
 }
}, {
 $group: {
  _id: '$activityId',
  records: {
   $push: '$$ROOT'
  },
  num: {
   $sum: 1
  }
 }
}]

  

 

取一段时间之后的数据

排除 部分数据

按 activityId 对数据进行分组,统计 & 组合为数组

posted @ 2022-08-26 14:26  PanPan003  阅读(22)  评论(0编辑  收藏  举报