I\'m usingSpring Boot v2.2.2.RELEASE
and Spring Data MongoDB
. In this example, I am looking perform group by department code and get all employees
Aggregations on repository methods do not support the Page
return type. Please have a look at the Reference Documentation for supported return types (eg. List
).
I created DATAMONGO-2506 to improve the error message in that case.
At least I was able to get the data with below query, but still struggling to make the data in the form of Pages
db.country.aggregate([
{
$group: {
_id: "$departments.deptCd", matches: { $push: '$$ROOT' }
},
$facet: {}
}
])
Reference from : Keeping field in mongodb group by and how to group in mongoDB and return all fields in result