@@ -340,54 +340,67 @@ The operation returns a document similar to the following:
340
340
"defaultReadConcern" : {
341
341
"level" : "majority"
342
342
}
343
-
344
343
345
344
Unset Global Default Read and Write Concern
346
345
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
347
346
348
- Consider a deployment with the following default read and write
349
- concern:
347
+ You can:
348
+
349
+ - Unset the global default read concern.
350
+ - Only unset the global default write concern if you haven't already
351
+ set it.
352
+
353
+ For example, assume the global default read concern is set to
354
+ :readconcern:`level: "majority" <"majority">`. To unset the global
355
+ default read concern, use an empty document ``{}``:
356
+
357
+ .. code-block:: javascript
358
+
359
+ db.adminCommand( {
360
+ "setDefaultRWConcern" : 1,
361
+ "defaultReadConcern" : {}
362
+ } )
350
363
364
+ The operation returns a document that indicates the operation was
365
+ successful:
351
366
352
367
.. code-block:: javascript
353
368
:copyable: false
354
369
355
370
{
356
- "defaultWriteConcern" : {
357
- "w" : "majority"
358
- } ,
359
- "defaultReadConcern" : {
360
- "level" : "majority"
361
- } ,
362
- "updateOpTime" : Timestamp(1586290895, 1 ),
363
- "updateWallClockTime" : ISODate("2020-04-07T20:21:41.849Z") ,
364
- "localUpdateWallClockTime" : ISODate("2020-04-07T20:21:41.862Z"),
365
- "ok" : 1,
366
- "$clusterTime" : { ... }
367
- "operationTime" : Timestamp(1586290925, 1 )
371
+ defaultReadConcern : { level: 'local' },
372
+ defaultWriteConcern: { w: 2, wtimeout: 0 },
373
+ updateOpTime: Timestamp({ t: 1656696934, i: 1 }) ,
374
+ updateWallClockTime: ISODate("2022-07-01T17:35:40.578Z"),
375
+ defaultWriteConcernSource: 'global',
376
+ defaultReadConcernSource: 'implicit' ,
377
+ localUpdateWallClockTime: ISODate("2022-07-01T17:35:40.578Z" ),
378
+ ok: 1 ,
379
+ '$clusterTime': {
380
+ ...
381
+ },
382
+ operationTime : Timestamp({ t: 1656632593, i: 1 } )
368
383
}
369
384
370
- The following operation unsets the global default read and write
371
- concern settings:
385
+ You can only unset the global default write concern if you haven't
386
+ already set it.
387
+
388
+ To unset the global default write concern, use an empty document ``{}``:
372
389
373
390
.. code-block:: javascript
374
391
375
- db.adminCommand({
376
- "setDefaultRWConcern" : 1,
377
- "defaultReadConcern" : {},
378
- "defaultWriteConcern" : {}
379
- })
392
+ db.adminCommand( {
393
+ "setDefaultRWConcern" : 1,
394
+ "defaultWriteConcern" : {}
395
+ } )
380
396
381
- The operation returns a document similar to the following:
397
+ If the global default write concern is:
398
+
399
+ - Unset, the operation succeeds.
400
+ - Already set, the operation returns the following error.
382
401
383
402
.. code-block:: javascript
384
403
:copyable: false
385
404
386
- {
387
- "updateOpTime" : Timestamp(1586290895, 1),
388
- "updateWallClockTime" : ISODate("2020-04-07T20:21:41.849Z"),
389
- "localUpdateWallClockTime" : ISODate("2020-04-07T20:21:41.862Z"),
390
- "ok" : 1,
391
- "$clusterTime" : { ... }
392
- "operationTime" : Timestamp(1586290925, 1)
393
- }
405
+ MongoServerError: The global default write concern cannot be unset
406
+ once it is set.
0 commit comments