MongoDB $aggregate $push multiple fields in Java Spring Data

You can directly pass the BasicDbObject to any of the aggregation pipeline stage.

Aggregation agg = newAggregation(
            group("title").
            push(new BasicDBObject
                   ("version", "$version").append
                   ("author", "$author").append
                   ("dateAdded", "$dateAdded")).as("versions"));

Leave a Comment