You can perform bulk delete operations on multiple documents in Compass by using the Delete Documents modal. This helps you visualize deletes before applying them.您可以使用“删除文档”模式在Compass中对多个文档执行批量删除操作。这有助于您在应用删除之前将其可视化。
About this Task关于此任务
Deleting documents is a permanent action and cannot not be undone. Validate documents in the Preview of the Delete Documents modal before confirming the delete operation.删除文档是一项永久性操作,无法撤消。在确认删除操作之前,在“删除文档”模式的“预览”中验证文档。
Before you Begin开始之前
The Delete Documents modal is available starting in Compass version Compass 1.42.0. For instructions on updating or installing the latest Compass version, see Download and Install Compass.1.42.0版本开始提供“删除文档”模式。有关更新或安装最新Compass版本的说明,请参阅下载和安装Compass。
Steps步骤
Apply a query filter应用查询筛选器
From the Documents tab, input a query into the Query Bar to filter deleted documents. To delete all documents in the collection, leave the Query Bar blank.从“文档”选项卡中,在“查询栏”中输入查询以筛选已删除的文档。要删除集合中的所有文档,请将“查询栏”留空。
Open the Delete Documents modal打开“删除文档”模式
On the Documents tab, either right-click the query bar or its surrounding whitespace and select Bulk delete from the dropdown, or click the Delete button, to display the Delete Documents modal. The following table summarizes the UI of the modal:在“文档”选项卡上,右键单击查询栏或其周围的空白,然后从下拉列表中选择“批量删除”,或单击“删除”按钮,显示“删除文档”模式。下表总结了该模式的用户界面:
| Query(查询) | |
| Export(导出) | |
| Preview(预览) |
(Optional) Export the Delete(可选)导出删除
You can export the Delete query to a supported driver language using the Export button on the Delete Documents modal.您可以使用“删除文档”模式上的“导出”按钮将“删除”查询导出为支持的驱动程序语言。
On the Delete Documents modal, click Export. The Export Delete Query To Language modal displays with the delete syntax populated under My Delete Query.在“删除文档”模式中,单击“导出”。将“导出删除查询到语言”模式显示,并在“我的删除查询”下填充删除语法。Select a programming language from the drop-down under Exported Delete Query. You can convert the command to C#, Go, Java, Node, PHP, Python, Ruby, or Rust. The field below displays the converted syntax.从“导出删除查询”下的下拉列表中选择一种编程语言。您可以将命令转换为C#、Go、Java、Node、PHP、Python、Ruby或Rust。下面的字段显示转换后的语法。(Optional) Click the Include Import Statements checkbox to include the required import statements for the selected programming language.(可选)单击“包含导入语句”复选框,以包含所选编程语言所需的导入语句。Click the icon to copy the converted syntax.单击图标复制转换后的语法。Click Close.单击“关闭”。
Example示例
The following example deletes two documents from the 以下示例从sample_mflix数据集中的movies collection in the sample_mflix dataset.movies(电影)集合中删除两个文档。
In the Query Bar, enter a filter for movies with a 在“查询栏”中,输入year of 1919.1919年电影的筛选器。
{ 'year' : 1919 }
Click the Delete button, the Delete Documents modal displays.单击“删除”按钮,将显示删除文档模式。
The Preview pane shows the documents included in the delete operation.“预览”窗格显示删除操作中包含的文档。
Click Delete Documents. A confirmation modal displays.单击“删除文档”。将显示确认模式。
Click the red Delete Documents button to confirm the operation.单击红色的“删除文档”按钮以确认操作。