-
Notifications
You must be signed in to change notification settings - Fork 1.7k
/
Copy pathMongo.getWriteConcern.txt
103 lines (67 loc) · 2.43 KB
/
Mongo.getWriteConcern.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
=======================
Mongo.getWriteConcern()
=======================
.. default-domain:: mongodb
.. contents:: On this page
:local:
:backlinks: none
:depth: 1
:class: singlecol
Definition
----------
.. method:: Mongo.getWriteConcern()
:returns: The current :term:`write concern` for the :method:`Mongo()
<db.getMongo()>` connection object.
See the :ref:`write-concern` for an introduction to write concerns
in MongoDB.
Compatibility
-------------
This method is available in deployments hosted in the following environments:
.. include:: /includes/fact-environments-atlas-only.rst
.. include:: /includes/fact-environments-onprem-only.rst
Syntax
------
The command takes the following form:
.. code-block:: javascript
db.getMongo().getWriteConcern()
This operation returns a document with the following values:
.. code-block:: javascript
:copyable: false
{ w: <value>, wtimeout: <number>, j: <boolean> }
The fields are:
.. list-table::
:header-rows: 1
* - Field
- Description
* - ``w``
- The number of :binary:`~bin.mongod` or :binary:`~bin.mongod`
instances that must acknowledge a write. Possible values are:
- "majority". A majority of the target instances must
acknowledge the write.
- <number>. The specified number of target instances must
acknowledge the write.
- <custom write concern name>. A user defined write concern, the
tagged instances must acknowledge the write.
See :ref:`write concern specification <wc-w>` for details.
* - ``j``
- A boolean value. ``j: true`` requests acknowledgment that the
write operation has been written to the :ref:`on-disk journal
<journaling-internals>`.
* - ``wtimeout``
- The number of milliseconds to wait for acknowledgment of the
write concern. ``wtimeout`` is only applicable when ``w`` has a
value greater than ``1``.
Example
-------
To return the current write concern, enter the following:
.. code-block:: javascript
db.getMongo().getWriteConcern()
When a write concern is specified using
:method:`Mongo.setWriteConcern()`, the output of
``Mongo.getWriteConcern()`` is similar to:
.. code-block:: javascript
WriteConcern { w: 2, wtimeout: 1000, j: true }
The ``Mongo.getWriteConcern()`` command returns an empty line if no
write concern has been specified.
.. seealso::
- :method:`~Mongo.setWriteConcern()`