I have a query like this (simplified):
db.report.aggregate([{ $match: { main_id: ObjectId("58f0f67f50c6af16709fd2c7") } }, { $group: { _id: "$name", count: { $sum: 1 }, sum: { $sum: { $add: ["$P31", "$P32"] } } } } ])
I am making this request from java and I want to display it in my class, but I do not want the "_id" to be displayed in the "name" field. Because if I do something like this:
@JsonProperty("_id") private String name;
then when I save this data back to mongo (after some modification), the data is saved with a name like "_id", while I want a real identifier to be created.
So how can I rename '_id' after the $ group operation?
source share