Is it possible with Spring-Data-MongoDB to update multiple fields of a document with one query.
For example, I can run this mongo query:
db.customers.update(
{"firstname": "Max"},
{
$set: {
"lastname": "Maier",
"email": "[email protected]"
}
}
);
How can we achieve this with code and the spring MongoTemplate? For example here is the code to udpate one value:
Query select = Query.query(Criteria.where("firstname").is("Max"));
Update updateValue = Update.update("lastname", "Maier");
UpdateResult updateResult = mongoTemplate.updateFirst(select, updateValue, Customer.class);
It seems that the Update#set method accepts only one (key, value) and no multi-values or list of values.