Knowledge base · Studio 3T Desktop IDE

Query Code

By Kathryn Vargas, Kirsty Burgess · Updated

Query Code is Studio 3T’s code generation tool that automatically converts queries to MongoDB syntax, JavaScript, Java, C#, Python, PHP, and Ruby.

With a single-click, you can translate queries or aggregations into code you can use in your applications.

You can also ease the transition from SQL to MongoDB and instantly generate the equivalent MongoDB syntax for your SQL queries.

Basics

Query Code automatically translates queries to the following languages:

  • JavaScript (Node.js)
  • Java (2.x, 3.x, 4.x driver API)
  • C#
  • Python
  • PHP
  • Ruby

Simply click Query Code to view the generated code in the following areas of the application:

  • Collection Tab – Drag and drop fields to build queries with the integrated Visual Query Builder. No need to understand JSON, simply run queries and Studio 3T shows you the results together with the MongoDB query code.
  • Aggregation Editor – Studio 3T’s aggregation pipeline builder. Build MongoDB aggregations in stages and view the flow of data into and out of each stage. Convert the entire pipeline directly into Javascript, Python, and more.
  • SQL Query – Query MongoDB with SQL statements and joins, and see how they translate to the MongoDB Shell language.
  • IntelliShell – Studio 3T’s built-in MongoDB Shell. Write queries fast and reduce errors with auto-completion and real-time error highlighting.

The image below shows the generated JavaScript code for a simple MongoDB query that’s been built with the Visual Query Builder:

Query Code shows the equivalent JavaScript code for a query built by dragging and dropping fields from a collection in the Visual Query Builder.

Convert SQL to MongoDB query code

Watch the video below to learn how you can write a simple SQL SELECT statement and convert it to a MongoDB query:

Watch the video on Vimeo

Open MongoDB Shell code directly in IntelliShell

You can continue developing the MongoDB Shell code in IntelliShell. IntelliShell allows you to write queries faster with auto-completion on field names, collection names, shell methods, JavaScript standard library functions, and more.

In SQL Query and the Aggregation Editor, with MongoDB Shell selected as the target language, click on Open in IntelliShell.

Open mongo shell code directly in IntelliShell

In the Collection Tab, click on Open Query in and select IntelliShell from the list:

In the Collection Tab toolbar, choose IntelliShell in the Open query in drop-down to develop your query in Studio 3T's built-in shell.


Discover other ways Studio 3T can help you save time:

With your consent, we and third-party providers use cookies and similar technologies on our website to analyse your use of our site for market research or advertising purposes, including personalized advertising (“performance”), to provide you with additional functions (“functional”), and to show content from social media platforms, such as embedded videos (“social media”). This may result in the creation of pseudonymous usage profiles and the transfer of personal data to third countries, including the USA, which may have no adequate level of protection for the processing of personal data. Please choose for which purposes you wish to give us your consent and store your preferences by clicking on “Accept selected”. You can find further information in section 9 of our Privacy Policy.

Manage consent preferences