首页 / MONGODB / mongodb聚合查询
mongodb聚合查询
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了mongodb聚合查询,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含3070字,纯文字阅读大概需要5分钟。
内容图文
); List<AggregationOperation> operations = new ArrayList<>(); operations.add(Aggregation.match(Criteria.where("planId").in(planIds).and("attendenceTime").lte(now))); operations.add(Aggregation.group("userId","planId") .max("attendenceTime").as("attendenceTime").first("memberId").as("studentId").first("planId").as("planId") .first("memberNumber").as("studentNumber").first("username").as("studentName") .first("schoolId").as("schoolId") .first("address").as("lastAttendenceAddress").first("orgEntity.className").as("className"). first("orgEntity.depId").as("depId").first("orgEntity.depName").as("depName") ); long currPage = 0,pageSize=5000; operations.add(Aggregation.sort(Sort.Direction.DESC, "attendenceTime")); // operations.add(Aggregation.skip(currPage*pageSize)); // operations.add(Aggregation.limit(pageSize)); Aggregation aggregation = Aggregation.newAggregation(operations); AggregationResults<GxyWarnEntity> g = template.aggregate(aggregation, MongoMoguAttendenceDto.class); //mongodb考勤中存在的数据 List<GxyWarnEntity> unSignins = g.getMappedResults();Executing aggregation: [ { "$match" : { "planId" : { "$in" : [ "176715c10b0960b161c6181e0532e779" , "3ffb1d4e001135129ede50d1678e5769" , "496af0ea0bdb2b93cc0c37618e0164d8" , "5274d63c8118b5918ae920b8b7ee934c" , "6d2addfc568480c3885b24dd95dba625" , "71b51a042312f3f79d02b7aa8d037829" , "7a5cb250a1024ba69f4d9cec1bdf0d55" , "9b18ecad83517b50510b05891ba9b03d" , "a2f684015bbb8ce4dec986b898213e01" , "b60ae3e53fc64d41b7ff8f3b2dc4be23" , "bb415eb63ed180a3c5429db733916aca" , "bc94d68734b804d3202ff7aafc2de913" , "bcfe591d84295d5354c2db76e107e3ad" , "c6477c9a99df81a9c706354d4833f73e" , "cbf55d8d12ad49c93e84101ad58fb89e" , "cc234b70807bb9d1ec7994760f6b6082" , "d1f133cd90bb392fd3e06745c31b8be3" , "d6d9d190d8d2c9a92dca48c2343bc1eb" , "db6921794544332510c322c748cf9a39" , "de372c4f38172841bad23d34090643a3" , "df7abbd3434ecdb4604554d400b9071d" , "e5916f5bfc580e7a0358195f76778f07" , "e683132a2fd4f06065b02e08eb457506" , "f077795af34b7fa924103f3dc8cbef40" , "f8cc095f62eddcf08aba2141604e8c66" , "f9a5542a4cbde051de19cb3e43443165" , "fc10da03eb1ea8f107ef2717cdd1bb07"]} , "attendenceTime" : { "$lte" : { "$date" : "2019-10-08T06:51:36.503Z"}}}} , { "$group" : { "_id" : { "userId" : "$userId" , "planId" : "$planId"} , "attendenceTime" : { "$max" : "$attendenceTime"} , "studentId" : { "$first" : "$memberId"} , "planId" : { "$first" : "$planId"} , "studentNumber" : { "$first" : "$memberNumber"} , "studentName" : { "$first" : "$username"} , "schoolId" : { "$first" : "$schoolId"} , "lastAttendenceAddress" : { "$first" : "$address"} , "className" : { "$first" : "$orgEntity.className"} , "depId" : { "$first" : "$orgEntity.depId"} , "depName" : { "$first" : "$orgEntity.depName"}}} , { "$sort" : { "attendenceTime" : -1}}] in collection mogu_attendance
mongodb聚合查询
标签:bcf style lis lan size school criteria ons user
本文系统来源:https://www.cnblogs.com/z360519549/p/11636824.html
内容总结
以上是互联网集市为您收集整理的mongodb聚合查询全部内容,希望文章能够帮你解决mongodb聚合查询所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。