Skip to content

Toro Cloud Dev Center

MongoDB query editor

The MongoDB query editor is Martini's dedicated editor for MongoDB queries. This editor is displayed when you open a MongoDB query file (.mongo). It features content-assist and validation to help you create your queries faster and with ease.

MongoDB query editor

When creating a MongoDB query, you must provide a value for each of these fields:

  1. Connection, which indicates the MongoDB database connection to query;
  2. Database, which indicates the database in the connection to query;
  3. Collection, which indicates which collection in the database to query; and
  4. Query Type, which indicates the type of query to execute.

Format your MongoDB query

Martini can also format your query. To do this, right click on the query editor, and select Format. Formatting can also be triggered by using the shortcut .

Creating a new MongoDB query

To create a new MongoDB query, right-click on the queries directory of the server which contains the connection you would like to query against, and choose New > MongoDB Query. If you're in the Database perspective, the queries directory will appear under the server itself in the Database Navigator; otherwise it will appear in the core package of the server in the Navigator.

Creating a new MongoDB query

Export a MongoDB query to a Gloop MongoDB service

You can create a Gloop MongoDB service from a MongoDB query file by right clicking the latter from the navigator and then choosing Export > Gloop MongoDB Service from the appearing context menu.

Martini Desktop Export MongoDB to Gloop Service

Content assist

The MongoDB query editor lets you write queries faster through content assist. With content assist, possible query fragments will be suggested as you write.

To trigger content assist, press . A pop-up will appear right under the line where you pressed the shortcut. This pop-up is composed of a search text field and a list of proposals.

Proposals are possible content that can be injected based on the current context; they have a name and a category. Proposals can be searched by their complete names or short names. You can use the and arrow keys to navigate through the proposals whilst still having focus on the search text so you can search and select at the same time.

Editor hotkeys

Pressing while the editor has focus will execute the query in the editor.

Exporting a MongoDB collection structure to a Gloop model

You can also export existing collection structures into Gloop models from the Database perspective. In order to do that, follow the steps below:

  1. Open the Database perspective.
  2. In the Database Navigator tree, expand the MongoDB connection that with the collection you would like to export.
  3. Expand a database of your choice.
  4. Right click the collection of your choice and select Export > MongoDB Collection to Gloop Model.
  5. In the dialog that appears, specify the location and name of your model. The Location and Name fields are pre-populated by default, and set to the code directory and the name of the schema table respectively.
  6. Click Finish.

Exporting a MongoDB collection to Gloop model

The Gloop model created from the collection is created by getting a sample of the collection to determine the structure.