1, "student" : "Maya", "homework" : [ 10, 5, 10 ], "quiz" : [ 10, 8 ], "extraCredit" : 0 } totalHomework : { $sum : $homework } totalQuiz : { $sum : $quiz } totalScore : { $add : [ "$totalHomework", "$totalQuiz", "$extraCredit“ ]} public void calculateTotalScore() { AggregationUpdate update = AggregationUpdate.update() .set(SetOperation.builder() .set("totalHomework").toValueOf(valueOf("homework").sum()) .and() .set("totalQuiz").toValueOf(valueOf("quiz").sum()) .and() .set("totalScore").toValueOf( valueOf("totalHomework") .add("totalQuiz") .add("extraCredit "))); mongoOperations.update(Student.class) .apply(update) .all(); } Expressive, Conditional Updates