|
| 1 | +.. _compass-bulk-delete: |
| 2 | + |
| 3 | +========================= |
| 4 | +Delete Multiple Documents |
| 5 | +========================= |
| 6 | + |
| 7 | +.. facet:: |
| 8 | + :name: genre |
| 9 | + :values: tutorial |
| 10 | + |
| 11 | +.. contents:: On this page |
| 12 | + :local: |
| 13 | + :backlinks: none |
| 14 | + :depth: 1 |
| 15 | + :class: singlecol |
| 16 | + |
| 17 | +You can perform bulk delete operations on multiple documents in Compass |
| 18 | +by using the :guilabel:`Delete Documents` modal. This helps you visualize |
| 19 | +deletes before applying them. |
| 20 | + |
| 21 | +About this Task |
| 22 | +--------------- |
| 23 | + |
| 24 | +Deleting documents is a permanent action and cannot not be undone. |
| 25 | +Validate documents in the :guilabel:`Preview` of the |
| 26 | +:guilabel:`Delete Documents` modal before confirming the |
| 27 | +delete operation. |
| 28 | + |
| 29 | +Before you Begin |
| 30 | +---------------- |
| 31 | + |
| 32 | +The :guilabel:`Delete Documents` modal is available starting |
| 33 | +in Compass version ``1.42.0``. For instructions on updating or installing |
| 34 | +the latest Compass version, see :ref:`download-install`. |
| 35 | + |
| 36 | +Steps |
| 37 | +----- |
| 38 | + |
| 39 | +.. procedure:: |
| 40 | + :style: normal |
| 41 | + |
| 42 | + .. step:: Apply a query filter |
| 43 | + |
| 44 | + From the :guilabel:`Documents` tab, input a query into the |
| 45 | + :guilabel:`Query Bar` to filter deleted documents. To delete |
| 46 | + all documents in the collection, leave the :guilabel:`Query Bar` blank. |
| 47 | + |
| 48 | + .. step:: Open the :guilabel:`Delete Documents` modal |
| 49 | + |
| 50 | + On the :guilabel:`Documents` tab, click the :icon-lg:`Trash` |
| 51 | + :guilabel:`Delete` button to display the |
| 52 | + :guilabel:`Delete Documents` modal. The following |
| 53 | + table summarizes the :abbr:`UI (User Interface)` of the modal: |
| 54 | + |
| 55 | + .. list-table:: |
| 56 | + :widths: 40 60 |
| 57 | + :header-rows: 1 |
| 58 | + |
| 59 | + * - UI Element |
| 60 | + - Description |
| 61 | + |
| 62 | + * - :guilabel:`Query` |
| 63 | + - Any filter criteria specified on the |
| 64 | + :guilabel:`Query Bar` applies to the |
| 65 | + :guilabel:`Delete Documents` modal. |
| 66 | + To update the :guilabel:`Query`, exit the |
| 67 | + :guilabel:`Delete Documents` modal and modify the |
| 68 | + query in the :guilabel:`Query Bar`. |
| 69 | + * - :guilabel:`Export` |
| 70 | + - Opens the :guilabel:`Export Delete Query To Language` |
| 71 | + modal, where you can convert the query to a supported |
| 72 | + driver language. |
| 73 | + * - :guilabel:`Preview` |
| 74 | + - A preview of the documents that will be deleted. |
| 75 | + |
| 76 | + .. step:: (Optional) Export the :guilabel:`Delete` |
| 77 | + |
| 78 | + You can export the :guilabel:`Delete` query to a |
| 79 | + supported driver language using the :guilabel:`Export` button on |
| 80 | + the :guilabel:`Delete Documents` modal. |
| 81 | + |
| 82 | + a. On the :guilabel:`Delete Documents` modal, click |
| 83 | + :guilabel:`Export`. The |
| 84 | + :guilabel:`Export Delete Query To Language` modal displays with |
| 85 | + the delete syntax populated under :guilabel:`My Delete Query`. |
| 86 | + |
| 87 | + #. Select a programming language from the drop-down under |
| 88 | + :guilabel:`Exported Delete Query`. You can convert the command |
| 89 | + to C#, Go, Java, Node, PHP, Python, Ruby, or Rust. The field below |
| 90 | + displays the converted syntax. |
| 91 | + |
| 92 | + #. (Optional) Click the :guilabel:`Include Import Statements` |
| 93 | + checkbox to include the required import statements for |
| 94 | + the selected programming language. |
| 95 | + |
| 96 | + #. Click the :icon-lg:`Copy` icon to copy the converted syntax. |
| 97 | + |
| 98 | + #. Click :guilabel:`Close`. |
| 99 | + |
| 100 | + .. step:: Delete your documents |
| 101 | + |
| 102 | + a. On the :guilabel:`Delete Documents` modal, click |
| 103 | + :guilabel:`Delete Documents`. |
| 104 | + #. Click the red :guilabel:`Delete Documents` button to confirm |
| 105 | + the operation. |
| 106 | + |
| 107 | + Compass deletes the documents that match the filter |
| 108 | + expression. |
| 109 | + |
| 110 | +Example |
| 111 | +------- |
| 112 | + |
| 113 | +The following example deletes two documents from |
| 114 | +the ``movies`` collection in the :ref:`sample_mflix dataset <sample-data>`. |
| 115 | + |
| 116 | +In the :guilabel:`Query Bar`, enter a filter for movies |
| 117 | +with a ``year`` of ``1919``. |
| 118 | + |
| 119 | +.. code-block:: javascript |
| 120 | + |
| 121 | + { 'year' : 1919 } |
| 122 | + |
| 123 | +Click the :icon-lg:`Trash` :guilabel:`Delete` button, the |
| 124 | +:guilabel:`Delete Documents` modal displays. |
| 125 | + |
| 126 | +The :guilabel:`Preview` pane shows the documents |
| 127 | +included in the delete operation. |
| 128 | + |
| 129 | +Click :guilabel:`Delete Documents`. A confirmation modal |
| 130 | +displays. |
| 131 | + |
| 132 | +Click the red :guilabel:`Delete Documents` button to confirm the |
| 133 | +operation. |
| 134 | + |
| 135 | +Learn More |
| 136 | +---------- |
| 137 | + |
| 138 | +- :ref:`compass-bulk-update` |
0 commit comments