Collection Tab“集合”选项卡
Posted on: 28/04/2018 (last updated: 08/10/2021) by Dakota Karlsson
- tl;dr
The Collection Tab is the starting point for all MongoDB data exploration and analysis in Studio 3T.Collection选项卡是Studio 3T中所有MongoDB数据探索和分析的起点。Here, access can be found to the Visual Query Builder, the Main Query Bar, and the other features associated with the current collection.在这里,可以访问“图形化查询生成器”、“主查询栏”以及与当前集合关联的其他功能。Try it today.Shortcuts快捷键Tab Content
The Collection Tab shows the contents of a MongoDB collection. “集合”选项卡显示MongoDB集合的内容。It’s made up of the Visual Query Builder, the Main Query Bar, the Results Tab, the Results Tab Toolbar, the Query Code tab, and the Explain tab.它由“图形化查询生成器”、“主查询栏”、“结果选项卡”、“结果选项卡工具栏”、“查询代码”选项卡和“解释”选项卡组成。

In the above screenshot, Customers is a collection whose documents are shown in the Collection Tab, indicated by the green border. 在上面的屏幕截图中,Customers
是一个集合,其文档显示在集合选项卡中,用绿色边框表示。Download the Customers collection to follow along the tutorial.下载Customers
集合,按照教程进行操作。
Visual Query Builder图形化查询生成器
The Visual Query Builder lets users create MongoDB queries via drag and drop. “图形化查询生成器”允许用户通过拖放创建MongoDB查询。Simply drag the desired field(s) to the query builder, drop it, set the operators, and run the query. 只需将所需字段拖到查询生成器中,将其拖放,设置运算符,然后运行查询。It supports all MongoDB operators and field values.它支持所有MongoDB运算符和字段值。
As the query is built in the Visual Query Builder, the equivalent query will be displayed in the Main Query Bar in the mongo shell syntax 由于查询是在“图形化查询生成器”中生成的,因此等效的查询将以mongo shell语法显示在主查询栏中
Read about the Visual Query Builder in full.全面阅读图形化查询生成器有关的信息。
Main Query Bar主查询栏

The Main Query Bar mirrors the query being built in the Visual Query Builder in JSON format which users can edit. “主查询栏”以JSON格式镜像正在“图形化查询生成器”中生成的查询,用户可以编辑该查询。It includes the Query, Projection, Sort, Skip, and Limit fields.它包括查询、投影、排序、跳过和限制字段。
This tool is especially useful for the experienced developer, but also helps new users gain familiarity with reading and using JSON to build queries.该工具对经验丰富的开发人员特别有用,但也可以帮助新用户熟悉阅读和使用JSON构建查询。
The Query Bar supports four short-hand query options to search by 查询栏支持四个按_id
:_id
搜索的快捷查询选项:
- ObjectId
(either single or double quoted).(单引号或双引号)。If the user enters如果用户把
57d28452ed5d4d54e8686f9d
into the query text field, it will be auto-expanded to输入到查询文本字段中,它将自动扩展为
{ "_id" : ObjectId("57d28452ed5d4d54e8686f9d") }
- UUID
(either single or double quoted).(单引号或双引号)。If the user enters如果用户把
C37E3CBA-8FAF-4923-818A-09D92AB56182
into the query text field, it will be auto-expanded to输入到查询文本字段中,它将自动扩展为
{ "_id" : UUID("C37E3CBA-8FAF-4923-818A-09D92AB56182") }
Integer整数. If the user enters。如果用户把
9876543210
into the query text field, it will be auto-expanded to输入到查询文本字段中,它将自动扩展为
{ "_id" : 9876543210 }
A single or doubled quoted string单引号或双引号字符串. If the user enters。如果用户把
"2020-12-12"
into the query text field, it will be auto-expanded to输入到查询文本字段中,它将自动扩展为
{ "_id" : "2020-12-12" }
The Query JSON Editor (“Multi-line Editor Tool”)查询JSON编辑器(“多行编辑器工具”)
While the Main Query Bar only shows parts of a query, the Query JSON Editor displays the entire query in JSON. 虽然“主查询栏”仅显示查询的一部分,但“查询JSON编辑器”以JSON显示整个查询。Here users can edit queries exactly how it would be done in the mongo shell.在这里,用户可以准确地编辑在mongo shell中的查询方式。
To open the Query JSON Editor, click the button to the left of the ‘play’ symbol in the Main Query Bar.要打开“查询JSON编辑器”,请单击主查询栏中“播放”符号左侧的按钮。

Double-check the code and click ‘Validate’ to ensure the query is being built correctly.仔细检查代码并单击“验证”以确保正确生成查询。
The Run Query Button (“Play”)“运行查询”按钮(“播放”)
Sitting directly to the right of the Query JSON Editor button, the Run (‘Play’) button runs the query on the respective collection. “运行”('Play')按钮直接位于“查询JSON编辑器”按钮的右侧,在相应的集合上运行查询。Additionally, this button contains a dropdown menu housing two other operations:此外,该按钮还包含一个下拉菜单,包含两个其他操作:
- “findOne(..)” –
returns a single entry matching query返回单个条目匹配查询 - “count(…)”. –
will return the number of documents matching the query将返回与查询匹配的文档数

Next to the Run button you’ll find a broom icon in the Query Bar. 在“运行”按钮旁边,你会在查询栏中找到一个扫帚图标。This will clear the query, projection, sort, skip, and limit parameters in one click.这将在一次单击中清除查询、投影、排序、跳过和限制参数。
Just above the Run Query and Query JSON Editor buttons are three additional buttons: Search Query History, Bookmark Query Manager, and Copy Query to Clipboard.“运行查询”和“查询JSON编辑器”按钮上方还有三个附加按钮:“搜索查询历史记录”、“书签查询管理器”和“将查询复制到剪贴板”。
Search Query History搜索查询历史记录
Shows all previous that have been run. 显示所有已运行的前一个。Queries are shown in JSON view.查询显示在JSON视图中。
Bookmark Query Manager书签查询管理器
Saves oft-used queries and eliminates the need to repeatedly enter queries manually.保存经常使用的查询,无需重复手动输入查询。
Copy Query to Clipboard将查询复制到剪贴板
Copies the query automatically to the users’ clipboard.将查询自动复制到用户的剪贴板。
Results Tab“结果”选项卡
The Results Tab offers three different options to view results and edit data: Tree View, Table View, and JSON View.“结果”选项卡提供了三种不同的选项来查看结果和编辑数据:“树形视图”、“表格视图”和“JSON视图”。

Tree View树形视图
Tree View allows for users to see the hierarchies in the data. “树形视图”允许用户查看数据中的层次结构。Additionally, data can be edited in-place. 此外,数据可以就地编辑。Read more about Tree View.阅读更多关于树形视图的信息。
Table View表格视图
Table View sorts data into columns and rows similar to a spreadsheet and enables custom views of embedded fields and sub-fields. “表格视图”将数据按类似于电子表格的列和行进行排序,并启用嵌入字段和子字段的自定义视图。As with Tree View, in-place editing is also available. 与“树形视图”一样,也可以进行就地编辑。Find full documentation of Table View here.在这里可以找到表格视图的完整文档。
JSON View视图
JSON View shows the data as JSON documents.
Drag-and-drop query building is not available while in JSON View. 在JSON视图中,拖放查询生成不可用。However, for fast in-place editing, select the target value and Cmd-J will bring up the JSON editor panel. 但是,对于快速就地编辑,选择目标值,Cmd-J将打开JSON编辑器面板。Read about JSON view here.在这里阅读JSON视图。
In-Place Data Editing就地数据编辑
In-place editing is available throughout Studio 3T. 整个Studio 3T都可以进行就地编辑。All three views – Table, Tree, and JSON – allow for data editing in real-time.这三个视图——表、树和JSON——都允许实时编辑数据。
In Tree and Table View, this is done by double-clicking on any field. 在“树形视图”和“表格视图”中,双击任何字段即可完成此操作。Additionally, a multi-line editor can be opened by clicking on the ellipsis icon.此外,单击省略号图标可以打开多行编辑器。
In JSON View, right-click anywhere in the Results Tab and choose Document > Edit Document. 在“JSON视图”中,右键单击结果选项卡中的任意位置,然后选择“文档”>“编辑文档”。This will open the Document JSON Editor.这将打开“文档JSON编辑器”。

The Results Tab Toolbar“结果”选项卡工具栏

Arrow keys方向键Use the arrow keys to flip through various results pages.使用“方向键”翻转各种结果页面。Results per page每页的结果数Choose to see 1, 10, 20, 50, or 100 results per page选择每页查看1、10、20、50或100个结果Refresh Documents刷新文档Click the refresh/recycle symbol to refresh results.单击“刷新/回收”符号以刷新结果。Add Document添加文档Creates a new object and allows users to input new data for the corresponding field.创建新对象,并允许用户为相应字段输入新数据。View Document查看文档Opens the current document in JSON view.在JSON视图中打开当前文档。Edit Document编辑文档Opens the document in JSON editor.在JSON编辑器中打开文档。Show Update Dialog显示更新对话框Opens a dialog screen where users can edit update settings.打开一个对话框屏幕,用户可以在其中编辑更新设置。Show Remove Dialog显示删除对话框Removes documents/fields matching a certain criteria.删除符合特定条件的文档/字段。Document Count in One Click一次点击即可计算文档数To count results, click the Count Documents button on the bottom right hand corner.要计算结果,请单击右下角的“计算文档”按钮。This returns the number of documents which match the query, in one click.一次单击即可返回与查询匹配的文档数。
Update Dialog更新对话框
The Update Dialog is a pop-up editor within the Collection Tab that allows you to modify several documents at once. “更新”对话框是“集合”选项卡中的弹出式编辑器,允许您一次修改多个文档。It is equivalent to the db.collection.updateMany() command in MongoDB.它相当于MongoDB中的db.collection.updateMany()
命令。
To access the Update Dialog, right-click on any cell in Table View or Tree View and choose Update Dialog.要访问“更新”对话框,请在“表视图”或“树视图”中的任意单元格上单击鼠标右键,然后选择“更新对话框”。
It has two tabs: Query and Update.它有两个选项卡:“查询”和“更新”。
The Query tab is where you write the query to find the documents you want to update.“查询”选项卡用于编写查询以查找要更新的文档。
You can choose to apply one of three predefined queries (all documents in the collection, selected documents in the collection, or the current results from the Collection View), but you can customize the query as needed in the editor.可以选择应用三个预定义查询(集合中的所有文档、集合中的选定文档或集合视图中的当前结果)之一,但可以根据需要在编辑器中自定义查询。

The Update tab is where you write the command that you want to run against your target documents, which you defined in the Query tab.“更新”选项卡用于编写要针对目标文档运行的命令,该目标文档是在“查询”选项卡中定义的。

Once done, click Validate JSON to debug, and click Update to finalize.完成后,单击“验证JSON”进行调试,然后单击“更新”完成。
Query Code查询代码
The Query Code tab allows user to convert queries into several different languages. “查询代码”选项卡允许用户将查询转换为几种不同的语言。The copy query to clipboard button will copy the code in the target language, thus allowing users to paste driver code easily into their desired application. “将查询复制到剪贴板”按钮将以目标语言复制代码,从而允许用户轻松地将驱动程序代码粘贴到所需的应用程序中。Currently the languages supported are: mongo Shell, JavaScript (Node.js), Java (2.x driver API), Java (3.x driver API), C#, and Python.目前支持的语言有:mongo
Shell、JavaScript(Node.js)、Java(2.x驱动程序API)、Java(3.x驱动程序API)、C#和Python。

Explain Tab“解释”选项卡
The Explain tab is one of the most powerful methods of fine-tuning query performance – it reveals how the query executes at the line level.“解释”选项卡是微调查询性能的最强大的方法之一,它揭示了查询在行级别的执行方式。
Older Studio 3T versions showed the query plan and execution statistics in this tree view:较旧的Studio 3T版本在此树视图中显示了查询计划和执行统计信息:

With the release of Studio 3T 2018.6 came Visual Explain, a feature which outlines the same information in an easier-to-follow diagram format.Studio 3T 2018.6的发布带来了图形化解释,这一功能以更易于理解的图表格式概述了相同的信息。

Learn more about Visual Explain in full here, and how you can use it to optimize MongoDB query performance.在此详细了解图形化解释,以及如何使用它优化MongoDB查询性能。