VOOZH about

URL: https://studio3t.com/knowledge-base/articles/query-code/

⇱ Query Code | MongoDB to JavaScript, Java, C#, Python, PHP & Ruby


👁 Studio 3T

HomeKnowledge Base

Query Code

Query Code is the automatic code generation feature that converts MongoDB, aggregation, and SQL queries to JavaScript (Node.js), Java (2.x and 3.x driver API), Python, C#, Ruby, and the mongo shell language.

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:

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.

This article was originally published by Kathryn Vargas and has since been updated.

Kirsty Burgess

We value your privacy

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 ("analytics and marketing") and to provide you with additional functions (“functional”). 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.

By clicking “Accept all”, you consent to the storage of cookies and the processing of personal data for these purposes, including any transfers to third countries. By clicking on “Decline all”, you do not give your consent and we will only store cookies that are necessary for our website. You can customize the cookies we store on your device or change your selection at any time - thus also revoking your consent with effect for the future - under “Manage Cookies”, or “Cookie Settings” at the bottom of the page. You can find further information in our Privacy Policy.
Cookie settings

Privacy Preference Center

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 ("analytics and marketing") and to provide you with additional functions (“functional”). 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 our Privacy Policy.


Manage consent preferences

👁 Image

Essential cookies are strictly necessary to provide an online service such as our website or a service on our website which you have requested. The website or service will not work without them.

👁 Image

Performance cookies allow us to collect information such as number of visits and sources of traffic. This information is used in aggregate form to help us understand how our websites are being used, allowing us to improve both our website’s performance and your experience.

Google Analytics👁 Image

Google Ads👁 Image

Bing Ads👁 Image

Facebook👁 Image

Quora👁 Image

Hotjar👁 Image

Reddit👁 Image

ZoomInfo👁 Image

👁 Image

Functional cookies collect information about your preferences and choices and make using the website a lot easier and more relevant. Without these cookies, some of the site functionality may not work as intended.

HubSpot👁 Image

👁 Image

Social media cookies are cookies used to share user behaviour information with a third-party social media platform. They may consequently effect how social media sites present you with information in the future.