|
| 1 | +.. _compass-read-only: |
| 2 | + |
| 3 | +==================================== |
| 4 | +Restrict Write Operations to MongoDB |
| 5 | +==================================== |
| 6 | + |
| 7 | +.. default-domain:: mongodb |
| 8 | + |
| 9 | +.. contents:: On this page |
| 10 | + :local: |
| 11 | + :backlinks: none |
| 12 | + :depth: 2 |
| 13 | + :class: singlecol |
| 14 | + |
| 15 | +You can use the ``readOnly`` option to prevent users from performing write |
| 16 | +operations to your MongoDB deployment through |compass-short|. If you enable the |
| 17 | +``readOnly`` option, users cannot modify documents, create indexes, or specify |
| 18 | +validation rules. |
| 19 | + |
| 20 | +About This Task |
| 21 | +--------------- |
| 22 | + |
| 23 | +By default, |compass-short| disables the ``readOnly`` option. |
| 24 | + |
| 25 | +If the ``readOnly`` option is enabled, you cannot enable the following options: |
| 26 | + |
| 27 | +- :ref:`enableShell <embedded-mongodb-shell>` |
| 28 | +- :ref:`enableDevtools <compass-enable-dev-tools>` |
| 29 | + |
| 30 | +Procedure |
| 31 | +--------- |
| 32 | + |
| 33 | +You can enable the ``readOnly`` option in either: |
| 34 | + |
| 35 | +- The |compass-short| :ref:`Settings panel <compass-settings-reference>` |
| 36 | + |
| 37 | +- The :ref:`command line <cli-options>` |
| 38 | + |
| 39 | +- A :ref:`configuration file <config-file>` |
| 40 | + |
| 41 | +|compass-short| Settings Panel |
| 42 | +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 43 | + |
| 44 | +.. procedure:: |
| 45 | + :style: normal |
| 46 | + |
| 47 | + .. step:: In the |compass-short| top menu bar, click :guilabel:`MongoDB Compass`. |
| 48 | + |
| 49 | + .. figure:: /images/compass/settings-panel-location.png |
| 50 | + :scale: 60% |
| 51 | + :alt: Settings panel location under the MongoDB Compass system menu |
| 52 | + |
| 53 | + Alternatively, you can use keyboard shortcuts to open the |
| 54 | + :guilabel:`Settings` panel: |
| 55 | + |
| 56 | + - Windows / Linux: ``Ctrl`` + ``,`` |
| 57 | + |
| 58 | + - Mac: ``⌘`` + ``,`` |
| 59 | + |
| 60 | + .. step:: In the :guilabel:`MongoDB Compass` menu, click :guilabel:`Settings`. |
| 61 | + |
| 62 | + |compass-short| opens a dialog box where you can configure your |compass| |
| 63 | + settings. |
| 64 | + |
| 65 | + .. step:: Toggle :guilabel:`Set Read-Only Mode`. |
| 66 | + |
| 67 | + .. step:: Click :guilabel:`Save`. |
| 68 | + |
| 69 | +Command Line |
| 70 | +~~~~~~~~~~~~ |
| 71 | + |
| 72 | +The following command starts |compass-short| from the command line and sets |
| 73 | +the ``--readOnly`` option: |
| 74 | + |
| 75 | +.. code-block:: sh |
| 76 | + |
| 77 | + <path-to-Compass-executable> --readOnly |
| 78 | + |
| 79 | +.. note:: |
| 80 | + |
| 81 | + The name and filepath of the |compass-short| executable depend on your |
| 82 | + operating system. |
| 83 | + |
| 84 | +Configuration File |
| 85 | +~~~~~~~~~~~~~~~~~~ |
| 86 | + |
| 87 | +You can specify the |compass-short| configuration file in either EJSON |
| 88 | +or YAML format. The following configurations set the |
| 89 | +``readOnly`` option to ``true``: |
| 90 | + |
| 91 | +EJSON |
| 92 | +````` |
| 93 | + |
| 94 | +.. code-block:: json |
| 95 | + |
| 96 | + { "readOnly": true } |
| 97 | + |
| 98 | +YAML |
| 99 | +```` |
| 100 | + |
| 101 | +.. code-block:: yaml |
| 102 | + |
| 103 | + readOnly: true |
| 104 | + |
| 105 | +Learn More |
| 106 | +---------- |
| 107 | + |
| 108 | +To learn more about the |compass| configuration file, see |
| 109 | +:ref:`config-file`. |
| 110 | + |
0 commit comments