All Studio 3T editions come with Visual Query Builder, a MongoDB query builder that works via drag-and-drop.

Instead of writing out complex MongoDB queries (which you can still do on Studio 3T through IntelliShell, our full MongoDB shell integration), the Visual Query Builder provides an intuitive interface that allows you to drag and drop fields while in Tree and/or Table View.

How to Query

  1. While in Tree/Table view, click on the Query Builder button on the top righthand side.Click on the Query Builder button
  2. In Table view, click on the field (not the field name!) and drag and drop it onto the Query Builder.
    Repeat for additional fields.Dragging a MongoDB field to the Query BuilderIn Tree view, you can drag and drop multiple fields at once:Meet Studio 3T's Visual Query Builder
  3. Update the operators and values under the Query, Projection, and Sort sections to show your desired results.
    Choose your standard operators in Query section.Choose your operators under the Query tabBy default, Studio 3T uses the $and operator to combine queries without the need to state it.  Almost always, you would only need to manually state the $or operator.
    For the query to work, make sure to first state the $or operator before defining the fields, as in the example below. $and and $or operators in Studio 3T's Visual Query BuilderYou can easily overwrite any string value, but you can always trigger a multiline text editor by clicking on the ellipsis (…) icon.The ellipsis icon triggers the multiline text editor in the Query BuilderWhen dragging and dropping fields, Studio 3T automatically detects the value type (e.g. Int32, string). But you can also change this manually by clicking on the Value icon.

    Update field value types directy in the Visual Query Builder

    Use the Projection section to explicitly include or exclude a field from your results.Use the Projection section to include or exclude fields from results And the Sort section to sort results by a particular field in ascending or descending order.Use the Sort section to sort results by fieldYou can also see how the written MongoDB query changes as you make updates in the Visual Query Builder, but note that any manual changes made in the Query section will not auto-update your selection in the Visual Query Builder.

    The Visual Query Builder also displays the written query simultaneously

  4. Once the correct values and operators are in place, you’re ready to run your query.
    Click on the Play button on top, or the Run button on the bottom of your screen.
    Running a MongoDB query on Visual Query Builder

Tips and Tricks

Document Count

You can always view how many results match your query by clicking on Count Documents on the bottom of all collection views.

Click on "Count Documents" to view the number of results

Order Documents by Creation Date

To display most recent documents, sort your MongoDB collection by the field _id in descending order, or in ascending order if you want to show oldest documents first.
Display most recent documents using the Sort operator

Skip and Limit

The Skip and Limit functions can save you querying time, especially when dealing with large datasets.

  • Skip – skips a certain number of documents (e.g. the first 5,000 documents)
  • Limit – limits your result to a certain documents (e.g. only show the first ten results)

Both functions can easily be defined in the Query Criteria section:
Use the Skip and Limit MongoDB functions when handling large datasets

Open Collections with Custom Page Size

On the note of saving time when handling large datasets, Studio 3T also lets you define the initial page size when opening a MongoDB collection.

Right-click on any collection, choose Open Collection with Custom Page Size, and define the initial page size.

Define the page size of any MongoDB collection you open

 

And there you have it: MongoDB made easy with Studio 3T’s Visual Query Builder! Make sure to read about our Aggregation Editor feature as well, which allows you to write aggregate queries in stages, so that you can ensure your results are always accurate.

Happy querying! 🙂