- Reference >
- Database Commands >
- Administration Commands >
- setUserWriteBlockMode
setUserWriteBlockMode¶
On this page
Definition¶
Syntax¶
The setUserWriteBlockMode
command has the following syntax:
The command takes the following fields:
Field | Type | Description |
---|---|---|
setUserWriteBlockMode |
integer | Set this field to 1 . |
global |
boolean | Blocks writes on a cluster when set to true . To enable writes on
a cluster, set global: false . |
Required Access¶
To execute the setUserWriteBlockMode
command, the user must
have the :authaction:`setUserWriteBlockMode` privilege.
Example¶
Enable user write block mode:
Add a record to the collection:
The server blocks the write because the user write block is enabled.
Example Output:
Disable user write block mode:
Add a record to the collection:
The :method:`~db.collection.insertOne()` method writes to a collection. The server allows the write because the user write block is disabled.