根据两字段乘积过滤查询分页数据

db.cron.aggregate([{$project:{_id:1,AppID:1,result:{$add:["$endlottery","$maxcount"]}}},{$match:{
AppID:123456,
result:{$gt : 1, $lte : 110}
}},{$sort:{result:-1}},{$skip:2},{$limit:3}]);

根据两字段乘积过滤查询总数

db.cron.aggregate([{$project:{_id:1,AppID:1,countaa:1,result:{$add:["$endlottery","$maxcount"]}}},{$match:{
AppID:123456,
result:{$gt : 1, $lte : 11}
}},{$group:{_id:null,countaa:{$sum:1}}}]);

 分组查询

db.user_cron_list.aggregate([{$match:{uid:10004339}},{$group:{_id:{cronid:"$cronid"}}}]);

 

参考:

http://www.runoob.com/mongodb/mongodb-aggregate.html

https://blog.csdn.net/xiangwangxiangwang/article/details/83277184

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-09-11
  • 2022-12-23
  • 2021-12-30
  • 2022-12-23
猜你喜欢
  • 2021-04-26
  • 2022-12-23
  • 2021-08-20
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案