In Compass 1.22 Beta we are introducing the integrated MongoDB Shell, which allows you to run database commands and scripts directly from Compass.
Compass is the easiest way to interact with your data in MongoDB: as we built it over time, we’ve always focused on simplicity and on exposing the features of the database through a user-friendly interface.
With this new version of Compass, we are offering a new way to work with MongoDB: when you need to go beyond what the UI offers, you can quickly pull up the shell, type any database command and see the results without having to go to the terminal and connect to your server or cluster again.
How it Works
When you are connected to a cluster in Compass, you will see that at the bottom there is a new “MongoSH Beta” component. If you click on that, you will have quick access to the integrated MongoDB Shell. The shell is already connected to your cluster and you can start typing commands right away.
Syntax Highlighting & Autocomplete
The integrated MongoDB Shell includes syntax highlighting to enhance readability and to make it easy to understand the structure of documents and command results and to quickly distinguish data types.
Additionally, the shell comes with intelligent autocomplete to help make sure you are writing the right commands or query operators and to save time when typing.
For example, in the screenshot below you can see how I used a simple script to grab all the documents in the collection, reformat the field names from camel-case to snake-case and then do an
insertMany() to insert the resulting documents back into a new collection.
What Comes Next
What you see in Compass 1.22 is just the beginning. With this first integration, we embedded the MongoDB Shell into the Compass UI so you don’t need to jump to the terminal and connect again to be able to run database commands and scripts.
The next thing we will be looking at is a deeper integration between the shell and the rest of the user interface. For example, when you run a
find() in the shell, the results will be available in the Documents tab. As this is something we are still designing and prototyping, your feedback is extremely valuable: feel free to reach out and let us know what you think.