I am trying to do the following query in morphia
db.notification.aggregate({ $match: { customerId: { $in: [ 4860.0, 4861.0, 4862.0 ] } } },
{ $sort: { creationDate: -1.0 } },
{ $group: { _id: { group: "$notificationGroup", customer: "$customerId" }, count: { $sum: 1.0 }, notifications: { $push: "$$ROOT" } } },
{ $group: { _id: "$_id.group", customers: { $push: { customer: "$_id.customer", count: "$count", notifications: "$notifications" } } } })
the only issue I have is trying to push multiple fields into the "customers" value.
in the source I see that Group.push is defined as
public static Accumulator push(final String field) {
return new Accumulator("$push", field);
}
also grouping cannot take another grouping, only a list of projections.
Is there a way to achieve
customers: { $push: { customer: "$_id.customer", count: "$count", notifications: "$notifications" } }
from the current API ?
next step for me is to try and a push method that can take a list, but I am just wondering if I am not missing something obvious in API.
cloned master from git so should be looking at latest version.