I am using mongodb-driver-sync:4.6.0
to update a field in my collection. The problem I am facing is that instead of evaluating the expression and putting the result into the field, the field is being set to that formula itself.
My code is:
BsonArray operands = new BsonArray();
operands.add(new BsonString("$percent"));
operands.add(new BsonDouble(1.5));
BsonDocument mult = new BsonDocument("$multiply", operands);
Bson update = set("revenue", mult);
collection.updateMany(filterQuarter, update);
The result I am getting this in my collection:
revenue: { '$multiply': [ '$percent', 1.5 ] }
I want this formula to be evaluated and the result put in my field. How do I do that?