update method
Performs an update on all documents matching the query filter using MongoDB update operators.
The update will be applied atomically on the server. If optimistic is true, the cache will be updated immediately with the expected changes, and then reconciled with the server response when it arrives. If optimistic is false, the cache will only be updated when the server confirms the update.
The update parameter should be a map containing MongoDB update operators like $set, $unset, $inc, $push, $pull, $addToSet, and $rename.
Implementation
Future<void> update({
JsonMap? $set,
JsonMap? $unset,
JsonMap? $inc,
JsonMap? $push,
JsonMap? $pull,
JsonMap? $addToSet,
JsonMap? $rename,
JsonMap? additionalUpdate,
JsonMap? filter,
bool optimistic = false,
}) {
final update = _buildUpdateMap(
set: $set,
unset: $unset,
inc: $inc,
push: $push,
pull: $pull,
addToSet: $addToSet,
rename: $rename,
additionalUpdate: additionalUpdate,
);
return _client.update(
_name,
update: update,
filter: filter ?? <String, dynamic>{},
optimistic: optimistic,
);
}