Companion¶
object Companion
Properties¶
FireAndForget¶
Requests are not acknowledged.
The MongoDB server will acknowledge having received the request, but will not communicate further, no matter what happens.
Use this write concern for requests where the result's loss is acceptable. For example, when storing high-volume sensor data, it may be acceptable if some measurements are lost when the cluster is overloaded.
Example¶
collections.updateMany(
options = {
writeConcern(WriteConcern.FireAndForget)
}
) {
User::age inc 1
}
See also
WithWriteConcern.writeConcern: Specify this option.
Majority¶
val Majority: WriteConcern
Requests acknowledgement from the majority of data-bearing members, as well as requesting that the write is written to the journal.
Use this write concern for requests where the result is important and shouldn't be lost. Note that some data may still be rolled back, see writeToJournal.
Example¶
See also
WithWriteConcern.writeConcern: Specify this option.
Primary¶
val Primary: WriteConcern
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¶
See also
WithWriteConcern.writeConcern: Specify this option.