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.

  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…

    8 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  ·  Usability  ·  Flag idea as inappropriate…  ·  Admin →
  2. Add support for db.exists() and collections.exists()

    Add a db.exists() and collections.exists() so that it is easy to check whether a database or a collection exists. This will help to reduce the propensity to inadvertently create new dbs and collections when running a script due to typos.

    5 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

    under review  ·  1 comment  ·  Commands  ·  Flag idea as inappropriate…  ·  Admin →
  3. 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  ·  Flag idea as inappropriate…  ·  Admin →
  4. creating an option to import csv files with semicolon separator

    There isn't an option to specify semicolon as delimiter on mongo shell when importing csv files. We are forced to import through MongoDB Compass when file has semicolon separator.

    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  ·  Commands  ·  Flag idea as inappropriate…  ·  Admin →
  5. 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  ·  Flag idea as inappropriate…  ·  Admin →
  6. Add a command to change date format when logrotate is used

    After testing db.adminCommand( { logRotate : 1 } ), the following file was generated:
    /var/log/mongodb/mongod.log.2021-07-05T15-09-17. It would be good to add command to change date format. E.g. yyyymmdd-hhmmss and also it could be specified as variable in mongod.conf

    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  ·  Commands  ·  Flag idea as inappropriate…  ·  Admin →
  7. Change naming conventions to more inclusive terms. For example "slaveDelay" to "workerDelay" or "rs.isMaster" to "rs.isMain"

    There is an initiative in the tech community to replace non-inclusive terms with more inclusive ones and I'd like to get the community's take on it. I think the biggest offenders are terminology referring to "slaves" and "masters", but I'm sure there are others that might fall into that category. Although I'm sure nobody meant any harm by using these terms, I think we can and should do better.

    I'm currently working my way through the m103 replication course and I see in replication configuring there's a term "slaveDelay". Also a "rs.isMaster()" method. I'm suggesting replacing "slave" with "worker" and…

    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

    started  ·  1 comment  ·  Commands  ·  Flag idea as inappropriate…  ·  Admin →
  8. 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

    0 comments  ·  Flag idea as inappropriate…  ·  Admin →
  9. Paginate shell output

    When running a query or a command that returns a long output, the content scrolls off the screen and cannot be seen without using the terminal scrollbar.

    It would be nice if the content would only scroll to screen boundaries and pause like more or less.

    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  ·  Flag idea as inappropriate…  ·  Admin →
  10. create custom role with list of collection

    currently, when creating a role, we need to list one collection per db for custom role

    db.getSisterDB('admin').createRole({role : 'readWriteCollectionXY',
    privileges : [ {resource : {db : "databaseA", collection : "***"}, actions : ["find", "insert", "update"]},
    {resource : {db : "database
    A", collection : "yyy"}, actions : ["find", "insert", "update"]} ],
    roles : []
    })

    having an option to list all the collections in one db with the same permission would be a nice thing to have.

    db.getSisterDB('admin').createRole({role : 'readWriteCollectionXY',
    privileges : [ {resource : {db : "database_A", collections : ["***", "yyy"] }, actions : ["find", "insert", "update"]} ],
    roles…

    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  ·  Commands  ·  Flag idea as inappropriate…  ·  Admin →
  11. Explain shell helpers for CRUD API

    The .explain() method in the shell works with some write methods (update, remove, findAndModify), but it doesn't work with the newer CRUD API.

    The missing explain methods are:

    "deleteMany",
    "deleteOne",
    "findOne",
    "findOneAndDelete",
    "findOneAndReplace",
    "findOneAndUpdate",
    "insertMany",
    "insertOne",
    "replaceOne",
    "updateMany",
    "updateOne"

    I think this would be especially helpful for new hires: explain is a good way to quickly find the code that implements a command.

    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  ·  Commands  ·  Flag idea as inappropriate…  ·  Admin →
  12. Option to show date in local timezone

    Currently MongoDB is storing date and time in UTC - which is good and should be that way.
    However, from the presentation (either via Compass/Shell), there should be a way to show the date and time based on locale time zone settings or an option to switch from UTC to local time zone.

    So for people who consume data right from MongoDB, they don't get confused with the data differences between UTC and their local time zone.

    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

    1 comment  ·  Flag idea as inappropriate…  ·  Admin →
  13. 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

    0 comments  ·  Security  ·  Flag idea as inappropriate…  ·  Admin →
  • Don't see your idea?

MongoDB Shell

Categories

Feedback and Knowledge Base