Export Queries to Your Favorite Programming Languages with MongoDB for VS Code

Massimiliano Marcon

In MongoDB for VS Code 0.7.0 we introduced the ability to export queries and aggregations that you’ve drafted in a playground to your favorite programming language. Going from prototype to code is now easier than ever.

At MongoDB, we spend a lot of time thinking about how we can make developer workflows as easy as possible. This is why last year we released MongoDB for VS Code, an extension that lets you easily work with MongoDB from your VS Code environment.

Since that first release, we have been looking at how developers use the extension and we have been talking to a lot of our users to understand what else we could add to make them even more productive.

Everybody we talked to, really enjoyed the ability to navigate and explore their data and keep an eye on their MongoDB collections right next to their application code. We also learned that a lot of our users take advantage of Playgrounds to prototype their queries and make sure they return the results they expect with the performance they expect.

”Code

Other developers go even further. They use Playgrounds as a way to keep track of all the queries and aggregations their application code runs in one central place and they store playground files in git repositories together with their code.

This is a great way to document what the code is supposed to do when it talks to MongoDB so that other engineers on the team can always have an up-to-date birds-eye view of how the application interacts with the database.

With this use case in mind, we found an opportunity to streamline the workflow even further. We asked ourselves: what if, Playground files could be used as the source of truth for all queries and aggregations and the actual application code could just be automatically generated from there?

With the most recent release of MongoDB for VS Code, we took the first step in this direction. You can now select queries and aggregations within your Playground files and translate them into your favorite programming language. We currently have support for Node.js, Python, Java, and C#.

”

With this new addition to our VS Code extension, we are hoping to make the process of designing and testing your queries and getting them into your application easier and more effective. If you try out this new functionality and you want to share your feedback, feel free to submit ideas or feature requests on our feedback portal or to reach out directly to me on Twitter.