write_concern – Tools for specifying write concern
Tools for working with write concerns.
Parameters:
- w: (integer or string) Used with replication, write operationswill block until they have been replicated to the specified numberor tagged set of servers. w=
always includes the replicaset primary (e.g. w=3 means write to the primary and wait untilreplicated to two secondaries). w=0 disables acknowledgementof write operations and can not be used with other write concernoptions. - wtimeout: (integer) Used in conjunction with w. Specify a valuein milliseconds to control how long to wait for write propagationto complete. If replication does not complete in the giventimeframe, a timeout exception is raised.
- j: If
True
block until write operations have been committedto the journal. Cannot be used in combination with fsync. Priorto MongoDB 2.6 this option was ignored if the server was runningwithout journaling. Starting with MongoDB 2.6 write operations willfail with an exception if this option is used when the server isrunning without journaling. - fsync: If
True
and the server is running without journaling,blocks until the server has synced all data files to disk. If theserver is running with journaling, this acts the same as the j_option, blocking until write operations have been committed to thejournal. Cannot be used in combination with _j.
acknowledged
If
True
write operations will wait for acknowledgement beforereturning.- The document representation of this write concern.
Note
WriteConcern
is immutable. Mutating the value ofdocument
does not mutate this WriteConcern
.