Skip to content

Collection tab and query bar

  • MongoDB

The collection tab shows the documents of a collection, view or time series collection. You type the query, projection and sort in mongosh syntax, or build them in the visual query builder docked at the right, and the generated find() text stays in step with both. The documents show a page at a time in Table, Tree or JSON View, and two more sections show the query as code and its plan.

Querybara's MongoDB collection view of catalog.products: a filter and sort in the query bar, the matching find() text below it, and the first product expanded in the tree view with its price and variants.Querybara's MongoDB collection view of catalog.products: a filter and sort in the query bar, the matching find() text below it, and the first product expanded in the tree view with its price and variants.
Filter, project and sort in mongosh syntax, with the find() text editable both ways and documents as a tree.
  • Click a collection, view or time series collection in the explorer, or choose Open Collection Tab from its menu.
  • Press Ctrl + P (Cmd + P on macOS) and type a few letters of its name.
  • Choose Collection in the toolbar. It asks which collection when none is in view.
  • Choose Open in collection tab on a find() result in IntelliShell, or Open in collection view in a SQL tab. The query comes with it.

The first page of documents loads at once. If the collection is already open, its tab comes forward. The breadcrumb at the top shows the connection, the database and the collection, and marks a view or a time series collection.

  1. Type into Query, Projection and Sort in mongosh syntax, for example { category: 'chairs', price: { $gt: 100 } }, and set Skip and Limit if you need them.
  2. Press Enter in any field, or choose Run in the toolbar.

The arrow beside Run offers three ways to run the query:

Item What it runs
find(…) The documents the query matches, a page at a time
findOne(…) The first document the query matches
count(…) How many documents the query matches

The find() line under the fields shows the query as a find() call:

db.products.find({ category: 'chairs', price: { $gt: 100 } }).sort({ price: -1 }).limit(20)

You can edit that text directly. The fields follow it, and Ctrl + Enter (Cmd + Enter on macOS) runs it.

A syntax error is shown under the field it is in, with its column; select the message to put the cursor there. Nothing runs until the query parses.

Reset clears the query.

Visual Query Builder at the right end of the toolbar docks the builder at the right of the tab; the fields stay visible and follow it. See Visual query builder.

The tab has three sections under the query bar:

Section What it shows
Result The documents, with the result toolbar above them.
Query Code The query as a program for a driver, or as a mongosh script. Open in IntelliShell opens the find() there. See Export query as code.
Explain The query plan. Run full explain runs the query and measures it; Plan only shows the chosen plan without running it. See Explain.

Explain in the toolbar runs the query and opens the Explain section. To open Query Code, press Ctrl + G (Cmd + G on macOS).

Pick Table View, Tree View or JSON View in the View list at the right of the result toolbar, or press Ctrl + Alt + 2, 1 or 3 (Cmd + Option on macOS). The next collection tab opens in the view you picked last; the first opens in Table View.

View What it shows
Table View One column per field, each with its BSON type. An array or sub-document cell is a link: select it to show its contents as a table. The breadcrumb above the table leads back. Nested fields as columns spreads sub-document fields into columns.
Tree View One row per document with its number and _id. Expand a document, or any sub-document or array in it, to see each field with its BSON type.
JSON View The documents as text, in mongosh syntax or as Relaxed EJSON. Copy puts the text on the clipboard.

In the table, drilling into an array of documents such as variants shows one row per element, and you can keep drilling into nested arrays (for example variants › [0] › tags). Choose Documents in the breadcrumb to return to the whole collection.

The result toolbar shows one page of documents at a time: 100 by default. Its pager has First page, Previous page, the page number, Next page and Last page; type a page number and press Enter to go to it. Beside it, the toolbar names the documents shown, such as “Documents 101 to 200”, and the refresh button runs the query again.

To change how many documents a page holds, open Page size (the gear beside the pager) and pick 50, 100, 500 or 1,000. The size you pick applies to every collection, and the tab starts again at page 1.

Pages stay inside the query’s own Skip and Limit; a Limit of 0 means no limit.

The footer shows how many documents are loaded and an estimate of the collection’s size. With a query, choose Count matches for the exact number of matching documents; without one, Count Documents counts the whole collection. Counting… Cancel stops a count. Once the total is known, the pager shows the number of pages. Last page counts first when the total is not known yet. The footer also shows how long the first page took.

  • Hover a document to show its Edit, Clone and Delete buttons, and use Insert, Bulk update… and Bulk delete… in the result toolbar. See Documents.
  • Double-click a value in Table View or Tree View to edit it in place.
  • Right-click a document for its menu: Edit Document…, Clone Document…, Insert Document…, Remove Document…, Copy Document, Copy All Documents, Copy as Extended JSON and Paste Documents…. On a value, the menu adds Edit Value, Remove Field…, Copy Value and Copy Field Path. See Copy and paste.
  • Export… and Import… in the result toolbar write what the query finds to a file, or read a file into the collection. See Import and export.

Some documents cannot be edited:

  • A view is read-only: its documents come from a pipeline.
  • A read-only connection shows the documents but does not change them.
  • With a projection, Edit and Clone are hidden and values cannot be edited in place; clear the projection to edit whole documents.

Every run goes into the app’s query history as its find() text.

  • History in the toolbar lists the queries run on this collection, newest first, with failed ones marked. Choose one to put it back in the query bar and run it.
  • Saved lists the queries saved for this collection; choose one to run it. Save Query… saves the query in the bar under a name, and Delete Saved Query removes one after asking. The query in the bar stays.

Saved queries are kept in the local store with the aggregation editor’s saved pipelines.

Open query in… takes the query to another tool:

Item Opens
IntelliShell IntelliShell with the find() text
Aggregation Editor The aggregation editor, starting with the query as a $match
SQL Query A SQL tab on the collection

The other tools sit under Tools, each with a line on what it does:

Tools menu item Opens
Indexes The index manager. Not offered for a view.
Schema Schema analysis.
Options Collection options.
Watch A change stream on the collection. Not offered for a view.

Documents Querybara 0.1.19 · built from89dc752