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.
When creating a MongoDB query, you must provide a value for each of these fields:
- Connection, which indicates the MongoDB database connection to query;
- Database, which indicates the database in the connection to query;
- Collection, which indicates which collection in the database to query; and
- Query Type, which indicates the type of query to execute.
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.
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.
Pressing while the editor has focus will execute the query in the editor.
Martini can also format your queries. To do this, right click on the query editor, and select Format. Formatting can also be triggered by using the shortcut .
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.
Exporting a MongoDB collection structure to a Gloop model
- Open the Database perspective.
- In the Database Navigator tree, expand the MongoDB connection that with the collection you would like to export.
- Expand a database of your choice.
- Right click the collection of your choice and select Export > MongoDB Collection to Gloop Model.
- 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
codedirectory and the name of the schema table respectively.
- Click Finish.
The Gloop model created from the collection is created by getting a sample of the collection to determine the structure.