I'm trying to convert this javascript code into java code to be used in Spring Data:
proj3={"$project": {
"comms" : 1,
"same" : { "$eq" : ["$comms.i" , "$max"]},
"max" : 1,
"_id" : 1
}
};
I cannot seem to figure it out.
I have tried this:
BasicDBObject o3 = new BasicDBObject();
o3.append("$eq", "[\"$comms.i\",\"$max\"]");
Aggregation aggCount2 = newAggregation(project("comms", "max", "_id").andExpression("same", o3));
logger.info(aggCount2.toString());
This is what is logged:
{ "$project" : { "comms" : 1 , "max" : 1 , "_id" : 1}}
I also read this thread: Spring Data MongoDB - $eq within $project support but the poster seemed to have given up and used the executeCommand option instead which is not the route I would like to go.
How can I get this code to work in java Spring Data Mongodb?