【发布时间】:2019-08-19 08:22:14
【问题描述】:
我正在开发一个 Spring Boot 项目并使用 MongoDB 作为我的数据库。
有一个包含学生文档的studentDB数据库,该文档包含以下字段:
_id 、学生姓名、参加讲座、iso_dom、iso_dow、iso_month、iso_year、iso_week"。
学生档案
_id Object
student_name String
attend_lecture int
iso_dom int date of the month ("1" January 2015)
iso_dow int day of the week (Friday)
iso_month int the month (1 stand for January)
iso_year int year (2015)
iso_week int week number (1)
我在这里尝试检索 2015 年 1 月 12 日至 2015 年 3 月 13 日期间有多少学生参加了讲座?
我尝试过的方法:
我在 MongoDB 中使用了带有小于和大于子句的聚合。
在检索 2015 年 1 月 12 日至 2015 年 3 月 13 日之间的所有日期时,我还使用了 part 子句的日期。
问题: 是否有任何可行的方法来检索 2015 年 1 月 12 日至 2015 年 3 月 13 日期间有多少学生参加了讲座?
示例:
学生档案
"_id":"5c1639b3a1b32bb04547137f",
"student_name":"MR. Rahul"
"iso_dom":12,
"iso_dow":3,
"iso_month":1,
"iso_week":12,
"isp_year":2018,
"attend_lecture":5
【问题讨论】:
标签: java mongodb spring-boot microservices aggregation