我正在尝试从MongoDB获取MyCustomObject的列表。我想例如从日期列按天分组的前1000条记录。我正在使用java和spring来做到这一点。我不确定如何使用此组聚合...它不返回任何内容。
这是我的Mongo数据的样子:
"_id" : "12345667890",
"_class" : "tst.class",
"hidden" : true,
"albumName" : "test-album",
"created" : {
"$date" : "2017-10-06T00:49:56.407Z"
},
"test" : {
......```
And this is how i am trying to use it from the java
``` Aggregation aggregation = Aggregation.newAggregation(
group("created").first("").as("latestCreatedDate"),
project("_id").and("testName").previousOperation());
AggregationResults<MyCustomObject> results = mongoTemplate.aggregate(aggregation, "objects", MyCustomObject.class);
我想要整个对象或至少_id