Navigation

    Run Commands in mongosh

    Info With Circle IconCreated with Sketch.Note
    Beta

    The MongoDB Shell (mongosh) is currently available as a Beta release. The product, its features, and the corresponding documentation may change during the Beta stage.

    For documentation of basic MongoDB operations in mongosh, see:

    To terminate a running command or query in mongosh, press Ctrl + C.

    Ctrl + C terminates the process in the shell, but does not terminate the process on the MongoDB server. This behavior differs from the db.killOp method, which terminates commands on the server.

    In scenarios where the output of a command includes { ok: 0 }, mongosh throws an exception and does not return the raw output from the server.

    Info With Circle IconCreated with Sketch.Note

    In the legacy mongo shell, when a command's output included { ok: 0 }, the behavior differs between commands. mongosh provides consistent behavior by always throwing an exception in these scenarios.

    Give Feedback