Massimiliano Marcon

10 results

The new MongoDB Shell is GA!

The new MongoDB Shell (mongosh) is now GA and becomes the default shell for the MongoDB platform. Download it now and start using it right away. Like all software we build at MongoDB, a great user experience is a major consideration. Even when working with a command-line tool, we believe it is just as important. To deliver this great experience to our users, we have redesigned the MongoDB Shell from the ground up to provide a modern command-line experience with enhanced usability features and a powerful scripting environment. After 1 year in beta, with a lot of great feedback from users and customers, we are excited to announce the general availability of the MongoDB Shell , the best way to work with your data and with your MongoDB deployments from the command line. The new MongoDB Shell is compatible with MongoDB 4.0+, so you don’t have to wait to upgrade to MongoDB 5.0 to start using it. You can download it and try it out now ! Enhanced user experience To make queries and aggregations easier to write and results easier to read, the MongoDB Shell comes with syntax highlighting. Now, it’s much easier to distinguish fields, values, and data types, which helps avoid syntax errors. If an error still occurs, the shell points you to the problem and helps you understand how to fix it. To help you type your queries and commands faster, the new MongoDB Shell includes intelligent autocomplete: based on the version of MongoDB you are connected to, the shell can suggest autocomplete options for methods, commands, and even MQL expressions. And when you don’t remember the syntax for a command, you can quickly look it up directly from the shell. Advanced scripting environment The MongoDB Shell is a great scripting environment. It’s built on top of the Node.js REPL, which means you can use the entire Node.js API in your scripts. Not only that: in your scripts for the MongoDB Shell you can now use any modules from npm. In the video below, you can see how I used node-fetch to fetch some data from a REST API and store it in MongoDB. Of course, you can also load and run scripts from the filesystem: as with the legacy mongo shell, in mongosh you can keep using load and eval to execute your scripts. Extensibility and snippets One of the goals we set for ourselves when we started building a new MongoDB Shell, was to make it easy to extend. This way, as the MongoDB platform grows with new products and services, the shell can grow with it. We also wanted to give our users and customers the possibility to extend the shell with all the functionality they need to be productive with MongoDB. While that has somewhat always been possible by loading scripts at startup with an RC file , we decided to take it one step further. In mongosh, we allow you to install Snippets. Snippets are plugins that you can install and are automatically loaded into the shell. Snippets can use any Node.js API and npm packages, allowing you to support a wide variety of use cases. We maintain a repository with a few Snippets that offer some new, interesting functionality (e.g. a snippet to analyze the schema of a given collection ) but you are free to configure mongosh to use a registry of snippets of your choice. Snippets are currently an experimental feature of mongosh. We are curious to see how you use it and get feedback so we can take it in the right direction and help you customize the shell exactly the way you need it. What happens with the legacy Mongo shell? You might be wondering what will happen with the legacy mongo shell. We are not taking it away quite yet. However, starting with MongoDB 5.0 the legacy shell is deprecated, and we encourage you to switch to mongosh as your default shell. Get started with mongosh! The new MongoDB Shell is available in our download center . Install it, connect with a MongoDB cluster and start scripting! Learn more about the MongoDB Shell and how to use it in our online documentation . If you have feedback or if you would like to suggest new features please let us know through our feedback engine .

July 12, 2021

New MongoDB Shell now supports Client-side Field-level Encryption

Last summer, we introduced mongosh , the new MongoDB Shell with an enhanced user experience and a powerful, Node.js-based scripting environment . Since then, we have been adding new functionality and APIs to close the gap with the legacy mongo shell, on the path to making it the default shell for MongoDB. In addition to the set of CRUD and other commands that we supported in the first release we recently added: Bulk operations Change Streams Sessions and Transactions Logging and profiling commands Replica set and Sharding configuration commands Plus some other minor things and utility commands here and there. This week, we released mongosh 0.8 with support for Client-side Field-level Encryption (FLE). Support for Client-side Field-level Encryption MongoDB Client-Side Field-level Encryption (FLE) allows developers to selectively encrypt individual fields of a document using the MongoDB drivers (and now with mongosh as well) on the client before it is sent to the server. This keeps data encrypted (but still queryable) while it is in-use in database memory, and protects it from the providers hosting the database, as well as from any user that has direct access to the database. Back in November, we announced that in addition to AWS’ KMS, Client-side FLE now supports key management systems in Azure and Google Cloud in beta. The most recent version of the MongoDB Shell makes it easy to test this functionality in a few easy steps: Create a free Atlas Cluster Install mongosh . Check out our documentation to set up your KMS in Azure or GCP. Start encrypting! To make it easier to get started with Client-Side FLE, here are two simple scripts that you can edit and copy-paste into mongosh: mongosh-fle-gcp-kms to set up Client-side FLE with Google Cloud and mongosh-fle-local-kms to use a local key. In the screenshot below, you can see a document that was encrypted on the client with automatic encryption before it was sent across the wire and inserted into MongoDB. Fields are in clear text in the shell but then are shown as encrypted when connecting with Compass to the same Atlas cluster. A Powerful Scripting Environment As mongosh is built on top of Node.js, it’s a great environment for scripting , no matter if it’s about checking the health status of your replica set or if you want to take a quick look at the data to make sure it’s coming in from your application as you are expecting. With modules from npm , the experience becomes much more rich and interactive. For example, if I want to look at the sample_mflix collection available in the Atlas sample datasets and check the distribution of thriller movies over the years, I can put together a simple script that includes running an aggregation and visually formatting the results with an open source library called babar This is just one of many ways you can extend the functionality of the MongoDB Shell by taking advantage of the great ecosystem of JavaScript libraries and modules that the community has built over the years and keeps on building every day. Start Scripting and Let Us Know How it's Working for You! As we added new functionality to the MongoDB Shell, we tried as much as possible to keep backwards compatibility with mongo, and we were mostly able to do that. In a limited number of cases, however, we took the opportunity to clean up the API and address some unexpected behaviors. Wondering what’s coming next in mongosh? We are working on adding support for load() and rc files to make it easy to load your scripts into the shell. If you find something that does not work as expected, please let us know! Simply create a bug in our JIRA project or reach out on Twitter .

February 22, 2021

What’s new in MongoDB for VS Code

A few months ago, we introduced MongoDB for VS Code , an extension to quickly connect to MongoDB and Atlas and work with your data right inside your code editor. Since then, over 85,000 of you have installed the extension, and based on your feedback, we improved the extension quite a bit and released a few new versions that added new functionality and extended the existing one. With this week’s release, we close the loop on what you can do with MongoDB for VS Code: You can choose the database and collection you want to query Make sure that you have the right indexes in place (an create new indexes if you don't) Search for documents with playgrounds Update your documents directly in the editor All of this with a workflow that is well integrated with the native VS Code functionality and its shortcut. Index View When you work with your data in MongoDB, no matter if you are building a cool application or if you are writing a Playground for an analytics query, you want to make sure your queries are covered by the right indexes. In MongoDB for VS Code that’s extremely easy to do: just select the collection you want in the tree view and all the information you need is right there. And if you see that the index you need is missing, we can prefill a playground with the command you need to create it. Quick Access to Document Search Once the right indexes are in place, jumping into a prefilled playground to find documents is just one click away. From there, you can just customize your query to find the documents you need. Results of a query – or of any playground, really – can also be saved into a file for later use or to share it with your colleagues. Just hit Ctrl/Cmd+S like you’d normally do with any file in VS Code and you are done. Edit Documents After you’ve found the documents you were looking for, you can open each one in its own editor view, edit it and save it back into MongoDB. Document editing was our most requested feature, and we are happy to have finally shipped it in our most recent release of MongoDB for VS Code and to have it built it in a way that fits within the natural VS Code user experience. VS Code Playgrounds + Node.js API + NPM Modules What I described above, is a normal flow when you work with a database: pick your db and collection, find the documents you are interested in, edit them and finally save the changes back to the database. MongoDB playgrounds are much more powerful than that though. First of all, you can use them to run any command that you’d run in the MongoDB shell: this means that playgrounds are effectively a shell replacement and a great way to write, edit and save long shell scripts in a full-featured editor. Second, in playgrounds, you have the entire Node.js API available to you and with a bit more work you can even require any module from NPM inside your playground code . Here’s how it’s done. Go to VS Code’s local settings folder ($HOME/.vscode on Linux/macOS or %USERPROFILE%/.vscode on Windows) and install a module from NPM. We’ll use cowsay as an example: $ npm i cowsay Now, go back to VS Code, connect to a MongoDB server or to an Atlas cluster and create the following playground: const cowsay = require('cowsay'); cowsay.say({ text : db.version() }); If everything works as expected, a cute cow should tell you what version of the server you are currently using. As you can see, the result of a playground does not have to be JSON documents. It can really be anything, and you can use any node modules out there to format it in the way you need it. This coupled with other VS Code extensions (one that I like a lot is Charts.js Preview for example) can make VS Code a powerful tool to query and analyze your data stored in MongoDB. Try it Now! If you are a VS Code user, getting started with MongoDB for VS Code is easy: Install the extension from the marketplace Get a free Atlas cluster if you don’t have a MongoDB server already Connect to it and start doing cool stuff with playgrounds You can find more information about MongoDB for VS Code and all its features in the documentation . Is there anything else you’d like to see in MongoDB for VS Code? Join in the discussion at the MongoDB Community Forums , and share your ideas using the MongoDB Feedback Engine .

January 26, 2021