Ruby Added to MongoDB Export to Language for Compass and VS Code
Thousands of developers rely on Compass as a GUI or VS Code as an integrated development environment to query their data in MongoDB. With both Compass and the official MongoDB Extension for VS Code, you can build a query or aggregation using the MongoDB Query API and export it to your chosen programming language.
The only limitation? Until now, only four languages have been supported for this feature in both tools: Java, Node.js, C#, and Python. Those four languages cover a significant percentage of the MongoDB developer community, but we knew we wanted to expand to help even more developers export queries/aggregations to their programming language of choice. To this end, we’re pleased to announce that the Export to Language features in both Compass and the VS Code Extension for MongoDB now support exporting to Ruby.
To build a query/aggregation in VS Code and export to Ruby, connect to your cluster in VS Code, create a Playground with code that draws on the Query API, and highlight your Query API syntax. From there, you will see a lightbulb icon that gives you the option to export to Ruby, among other languages.
You also have the option to export a sample query/aggregation including details on the driver usage so you start with a fully functional code snippet.
To build a query/aggregation in Compass and export to Ruby, simply connect to your cluster from Compass, navigate to the “Aggregations” tab, build your query/aggregation, and then click the button with an export icon immediately to the right of the “Save” button.
Once you’ve followed the above steps in VS Code or Compass, you’re ready to use the exported code in your Ruby app! For a peek under the hood at how MongoDB’s engineers added Ruby to Compass, check out this great article on Dev.to by Rachelle Palmer, Product Lead for Developer Experience at MongoDB.
We hope all the hardcore Rubyists out there find this new feature useful and that it makes it even easier to build Ruby apps with MongoDB. As you continue to use these tools within your application development cycle, don’t hesitate to reach out and give us feedback.