Export Query to Specific Language¶
New in version 1.15.0
You can export queries created in the query bar to one of the supported languages; Java, Node, C#, and Python 3. This feature facilitates reformatting and utilizing queries created in MongoDB Compass for use in your application.
- After constructing a query in the query bar, click to the right of the Reset button.
Select Export to Language:click to enlarge
In the Export Query To: dropdown, select your desired language:click to enlarge
The My Query pane on the left displays your query in
The pane to the right displays your query in the language selected.
- (Optional): Check the Include Import Statements option to include the required import statements for the language selected.
- (Optional): Check the Include Driver Syntax option to include application code for the language selected. If you include driver syntax, the copyable code reflects project, sort, maxtimems, collation, skip and limit options.
Click at the top-right of the formatted query to copy the query for the selected language to your clipboard. You can now easily integrate and execute your created query in your application.click to enlarge
- Click Close to return to the Documents Tab.