- Reference >
mongoshMethods >- Connection Methods >
- Mongo.setWriteConcern()
Mongo.setWriteConcern()¶
On this page
Definition¶
-
Mongo.setWriteConcern()¶ Sets the write concern for the
Mongo()connection object.See the Write Concern for an introduction to write concerns in MongoDB.
Syntax¶
The command takes the following form:
The fields are:
| Field | Description |
|---|---|
w |
The number of
See write concern specification for details. |
j |
A boolean value. j: true requests acknowledgment that the
write operation has been written to the on-disk journal. |
wtimeout |
The number of milliseconds to wait for acknowledgement of the
write concern. wtimeout is only applicable when w has a
value greater than 1. |
Example¶
In the following example:
- Two
mongodormongodinstances must acknowledge writes. - There is a
1second timeout to wait for write acknowledgements.
See also