Watch keynotes and sessions from MongoDB.live, our virtual developer conference.

Introducing the new MongoDB Shell

Today we introduced the first beta of the new MongoDB Shell (mongosh - mongo - es - eɪtʃ), a shell for MongoDB with a modern user experience that will grow in functionality along with the MongoDB data platform.

You can get the new shell from the MongoDB Download Center or if you are on macOS install it with Homebrew:

$ brew tap mongodb/brew
$ brew install mongosh

Read about it on the MongoDB Blog, try it out, and let us know what you think.

To know more about the MongoDB Shell and see demos of if, you can join MongoDB.live and join the “MongoDB Tools Everywhere” session.

9 Likes

Okay, I dont have to type .pretty() for the queries with larger document outputs - (it is pretty printing on its own). Also, noticed the MongoDB green in the syntax highlighting.

What branch of the repo is this if we want to clone directly, please?

Hooray!,

Looking forward to taking it out for a spin. I see from the .live keynote this is integrated in Compass and Jetbrainz IDEs!

Hi @Jack_Woehr,

You can find the code on GitHub repository: https://github.com/mongodb-js/mongosh
From a brief look, the master branch is sync’d with the latest tag release which is version 0.0.5.

Regards,
Wan.

2 Likes

Builds and runs, thanks, @wan
Ubuntu 18.04
Ubuntu 20.04
Fedora 32 Server

1 Like

Do we have full documentation to mongosh ?
I just tried db.version() in mongosh and got TypeError: db.version is not a function
So I think I need some help :slight_smile:

Hi @Jack_Woehr,

The documentation for mongosh can be found on https://docs.mongodb.com/mongodb-shell/
Currently mongosh (beta) supports a subset of the legacy mongo shell commands. Extending the MongoDB Shell API coverage is an ongoing effort.

This particular method is not currently covered in the documentation unfortunately.

There are a number of convenience wrappers/methods that only exists in the legacy mongo shell. A general work around is to find out what the wrapper is executing. You can execute the method without invoking it .i.e. minus the () for example:

> db.version
   function() {
      return this.serverBuildInfo().version;
   }

Then we can find out under mongo shell methods documentation what does serverBuildInfo does. i.e. db.serverBuildInfo(). With this knowledge we can then use it in mongosh:

db.runCommand( { buildInfo: 1 } ).version

If you have additional questions, it would be helpful if you can open a new topic discussion. This would help others with similar issues to find relevant topic easily.

Kind regards,
Wan.

3 Likes