0

So I have this large aggregation query in mongo that I am trying to do in Spring and in one of the aggregation I am doing a group by.

Here is the group

{ $group: 
{  
    _id: "$transferId",  
    "numTransfers": {    "$sum": 1  },   
    accountIds: {    $push: "$_id"  },  
    names: {    $push: "$name"  },  
    types: {    $push: "$transactionType"  },  
    descriptions: {    $push: "$description"  },  
    executionDates: {    $push: "$executionDate"  }} 
}

I am trying to have the Spring Mongo Group Operation reference the _id from the objects but it keeps getting me invalid reference.

UPDATED

Including Code that I have so far

GroupOperation groupOperation = group("transferId")
            .count().as("numTransfers")
            .push("_id").as("accountIds")
            .push("name").as("names")
            .push("transactionType").as("types")
            .push("description").as("descriptions")
            .push("executionDate").as("executionDates");

0 Answers0