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
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