Primary
Requests acknowledgement from the primary node only.
This ensures that the primary node has successfully handled this write operation. If the primary changes or dies before this write has been replicated, it may be rolled back. However, in most situations, this should be enough to ensure the data is stored.
Use this write concern for requests where the result should preferably not be lost, but rare rollbacks are acceptable in exchange for lower latency.
Example
collections.updateMany(
options = {
writeConcern(WriteConcern.Primary)
}
) {
User::age inc 1
}
Content copied to clipboard
See also
Specify this option.