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#, Python 3, Ruby, Go, Rust, and PHP. This feature allows you to reformat and use MongoDB Compass queries in your application.
Procedure
After constructing a query in the query bar, click to the right of the Reset button.
Click the Export to Language button
</>
:click to enlargeIn the Export Query To: dropdown, select your desired language:
click to enlargeThe My Query pane on the left displays your query in
mongo
shell syntax.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 enlargeClick Close to return to the Documents Tab.