Skip to content

MongoDB Shell

The MongoDB Shell (mongosh) lets you connect to MongoDB to work with your data and configure your database.

Help us improve the MongoDB Shell by posting your ideas and suggestions for improvements.

To report bugs, please use our MONGOSH JIRA project.

12 results found

  1. Vi mode for MongoDB Shell

    Please enable a 'vi' editing mode for the mongo shell.

    A first cut of key bindings would be:

    Basic command mode/editing mode toggling:
    i Insert before cursor
    Esc Toggle to command mode

    Cursor motion keys:
    h Move left
    j Move down
    k Move up
    l Move right

    w Move to next word
    b Move to the beginning of the word

    0 Move to the beginning of the line
    $ Move to the end of the line

    And delete/change:
    x delete next character to the right
    d

    {motion} delete amount specified by…

    11 votes

    We're glad you're here

    Please sign in to leave feedback

    Signed in as (Sign out)

    We’ll send you updates on this idea

    3 comments  ·  Usability  ·  Admin →
  2. Add support for AWS_PROFILE when authMechanism is MONGODB-AWS

    Currently, when using MONGODB-AWS, it can only read the following variables:

    AWS ACCESS KEY ID
    AWS SECRET ACCESS KEY
    AWS SESSION TOKEN

    which forces you to export credentials or to paste them in the CLI.

    AWS has a variable called AWS_PROFILE that will fetch the required values from your credential file, without having to paste them again. This variable is supported by anything using AWS SDK, so mongosh should have support for it as well.

    10 votes

    We're glad you're here

    Please sign in to leave feedback

    Signed in as (Sign out)

    We’ll send you updates on this idea

    0 comments  ·  Commands  ·  Admin →

    Hi there,


    Thank you for your feedback. We wanted to let you know this issue has been resolved starting mongosh version 2.2.0. Please find the latest version of mongosh here: https://www.mongodb.com/try/download/shell.


    Please let us know how else we could make your MongoDB Shell experience better!

  3. Support .mongorc.js file

    A core bit of functionality from the original shell is to support reading from the .mongorc.js file in a user's home directory. This feels like core functionality that mongosh should support.

    4 votes

    We're glad you're here

    Please sign in to leave feedback

    Signed in as (Sign out)

    We’ll send you updates on this idea

    0 comments  ·  Usability  ·  Admin →
  4. Ability to execute a javascript file from inside the shell

    Currently the only way to execute a javascript file from the mongo shell is to re-direct the input at shell login time (e.g. mongo --username <username> ... < myscript.js). It would be helpful to have a way to execute the script from inside the shell via some sort of "run" command (e.g.from inside the shell "run /my/path/myscript.js".

    4 votes

    We're glad you're here

    Please sign in to leave feedback

    Signed in as (Sign out)

    We’ll send you updates on this idea

    2 comments  ·  Commands  ·  Admin →
  5. Bracket matching and highlighting

    Something which I miss from the legacy shell is bracket matching and highlighting, so I can tell when I have too many brackets, or they're in the wrong order

    3 votes

    We're glad you're here

    Please sign in to leave feedback

    Signed in as (Sign out)

    We’ll send you updates on this idea

    0 comments  ·  Usability  ·  Admin →
  6. 3 votes

    We're glad you're here

    Please sign in to leave feedback

    Signed in as (Sign out)

    We’ll send you updates on this idea

    0 comments  ·  Commands  ·  Admin →
  7. mongosh and JSON: normalized output

    The CLI commands, like mongosh, can be used in bash scripts to quickly implement reliable data processing pipelines. Thanks to the aggregation pipeline your clients can do pretty complex things with this, despite a small number of lines and zero infrastructure. Unfortunately, in the recent versions, the output of those commands is no longer JSON. When mongosh returns results, it is now in pseudo-JSON, which can no longer be parsed directly by other standard tools like jq. This makes interpreting the results needlessly complicated. In addition, error messages are not output in JSON either (simple unformatted strings in that case),…

    2 votes

    We're glad you're here

    Please sign in to leave feedback

    Signed in as (Sign out)

    We’ll send you updates on this idea

    0 comments  ·  Scripting  ·  Admin →

    Starting with mongosh 1.6.0, it's now possible to pass a `--json` parameter to mongosh in conjunction with 

    `--eval`. For example:


    $ mongosh $CONNECTION_STRING --eval 'db.coll.stats()' --json=relaxed --quiet | jq '{storageSize,totalSize}'
    {
     "storageSize": 36864,
     "totalSize": 184320
    }


    If instead you are looking for a way to output JSON from a script, you can use `EJSON.stringify(thingToOutput, null, 2)`.

  8. Mongosh connection string thourgh proxy

    Greetings,
    I need to create a proxy host in my environment so that ALL traffic between client <->Mongo Atlas goes through ONE single host.
    Problem is that if I use mongodb+srv://server.example.com/
    It returns me one of 50 endpoints to my Atlas cluster.

    I need something like: connect to this cluster, BUT use this proxy hop server.

    1 vote

    We're glad you're here

    Please sign in to leave feedback

    Signed in as (Sign out)

    We’ll send you updates on this idea

    completed  ·  1 comment  ·  Usability  ·  Admin →
  9. Deal with // comments multiline history better

    This is a papercut in the legacy shell which would make the modern shell even more usable by comparison...

    Currently, both the new and legacy shell have an issue with the way they store a multiline command (eg. when defining an aggregation pipeline) as a single line in its history.

    Often (especially for aggregation pipelines) inputted commands will contain // comments. For example, see the code snippet 'var pipeline = [...];' here: https://www.practical-mongodb-aggregations.com/examples/simple-examples/group-and-total.html

    The reason why this shell behaviour is problematic is discussed in the Practical MongoDB Aggregations book chapter at https://www.practical-mongodb-aggregations.com/guides/composibility.html
    (scroll 2/3 down that page and read the…

    1 vote

    We're glad you're here

    Please sign in to leave feedback

    Signed in as (Sign out)

    We’ll send you updates on this idea

    Starting with version 1.0.6 of mongosh, single-line comments are replaced with /**/.

    There is no simple way to retain multi-line in history but I will split that into a separate suggestion to keep track of it.

  10. Control-C to cancel current execution only - without exiting from mongo shell

    when you started some complex query and realized that it could take time - you want to cancel it. if you press Control-C you will be kicked out of mongo shell. so you have to login back and switch to proper database; probably, set all variables again etc.

    there should be option to cancel just current execution leaving you in current session.

    1 vote

    We're glad you're here

    Please sign in to leave feedback

    Signed in as (Sign out)

    We’ll send you updates on this idea

    0 comments  ·  Usability  ·  Admin →

    This is available in mongosh 0.13.1+. When you do Ctrl-C, the shell will attempt to cleanly kill the operation on the server and get you back to the prompt right away.

  11. Add history search

    Add ability to search through the command history using Cmd/Ctrl+R. It would be nice to also being able to search through the scripts entered with .editor

    1 vote

    We're glad you're here

    Please sign in to leave feedback

    Signed in as (Sign out)

    We’ll send you updates on this idea

    completed  ·  2 comments  ·  Usability  ·  Admin →
  12. Allow for session timeouts

    For security reasons, it should be possible to configure a session timeout after which, if there has been no activity, the shell disconnects from MongoDB and the user has to reconnect.

    0 votes

    We're glad you're here

    Please sign in to leave feedback

    Signed in as (Sign out)

    We’ll send you updates on this idea

    completed  ·  1 comment  ·  Security  ·  Admin →
  • Don't see your idea?

MongoDB Shell

Categories

Feedback and Knowledge Base