Atomic Update
Select the target range with first/multi/upsertOne and explicitly configure document update or aggregation pipeline update.
First select the update range and expression.
text
Document update
java
• inc, set, unset, push, addToSet, pull
• Add Driver update directly: driverUpdate(Bson)
• setOnInsert(...) is used in upsertOne().document().
Single-document upsert
java
Pipeline update
java
nextStage() flushes the current pending $set as a single stage. Driver-native pipeline stages are added directly with stage(Bson).