id = "mongosh" name = "MongoDB Shell" homepage = "https://www.mongodb.com/docs/mongodb-shell/" description = "The MongoDB Shell is a fully functional JavaScript and Node.js REPL environment for interacting with MongoDB deployments." icon = "SimpleIcons:mongodb" executables = ["mongosh"] [dotfiles] # Two user-level files. # # https://www.mongodb.com/docs/mongodb-shell/mongoshrc/ — "On startup, mongosh # checks your HOME directory for a JavaScript file named .mongoshrc.js." # # The settings the `config` API writes live in mongosh's roaming data # directory, named `config` with no extension and written as EJSON. From # packages/cli-repl/src/config-directory.ts: # getStoragePaths(): on win32 shellRoamingDataPath = %APPDATA%/mongodb/mongosh, # otherwise $HOME/.mongodb/mongosh; ConfigManager.path() = roamingPath('config'). # The global config file (/etc/mongosh.conf, mongosh.cfg beside the binary) is # system-wide, so it is not listed. paths = [ "~/.mongoshrc.js", "~/.mongodb/mongosh/config", "%APPDATA%/mongodb/mongosh/config", ] # Both live in the same roaming directory as the config file. The history is # the REPL's transcript and the snippets directory is an npm checkout mongosh # manages itself. exclude = [ "~/.mongodb/mongosh/mongosh_repl_history", "%APPDATA%/mongodb/mongosh/mongosh_repl_history", "~/.mongodb/mongosh/snippets/", "%APPDATA%/mongodb/mongosh/snippets/", ] # The config file holds only the CliUserConfig keys (packages/types/src/index.ts): # display and logging preferences plus the telemetry flag. Connection strings # are passed on the command line, and .mongoshrc.js is a script the user wrote. secret = [] # No side_effect = false: `config.set(...)` in a live shell rewrites the file # from memory, so a running mongosh will clobber anything written under it. # logLocation is documented as "Directory where MongoDB Shell writes log files. # Specify an absolute filepath" — a directory on this machine's disk. The file # is named `config` with no extension, so format has to be declared; mongosh # writes it with EJSON.stringify, which is JSON. # It is written only when the user redirects the logs somewhere of their own # choosing, so the path is worth keeping to rebuild this machine and worth # nothing on the next one. [[dotfiles.machine_lines]] file = ["~/.mongodb/mongosh/config", "%APPDATA%/mongodb/mongosh/config"] format = "json" match = { key_path = ["logLocation"] } scope = "backup" [commands] format = 1 label = "Connect with the shell" description = "Open mongosh against a MongoDB deployment. Passwords are left out; mongosh prompts for one when needed." quality = "ai-draft" base = "fig:mongosh" parser = { end_of_options = "--", interleave = "permute", long_equals = true, short_attached = true, short_bundles = false } [[commands.source]] id = "fig" kind = "completion" url = "https://github.com/withfig/autocomplete/blob/master/src/mongosh.ts" license = "MIT" [[commands.field]] id = "uri" label = "Connection string" type = "string" position = 0 suggestions = [{ value = "mongodb://localhost:27017", label = "mongodb://localhost:27017" }] sources = ["fig"] [[commands.field]] id = "port" label = "Port" type = "integer" option = ["--port"] sources = ["fig"] [[commands.field]] id = "username" label = "Username" type = "string" option = ["--username", "-u"] sources = ["fig"] [[commands.field]] id = "auth_db" label = "Authentication database" type = "string" option = ["--authenticationDatabase"] sources = ["fig"] [[commands.field]] id = "eval" label = "Evaluate JavaScript and exit" type = "string" option = ["--eval"] sources = ["fig"] [[commands.field]] id = "shell" label = "Stay in the shell after --eval or a script" type = "boolean" option = ["--shell"] sources = ["fig"] [[commands.field]] id = "tls" label = "Use TLS" type = "boolean" option = ["--tls"] sources = ["fig"] [[commands.field]] id = "quiet" label = "Skip startup messages" type = "boolean" option = ["--quiet"] sources = ["fig"] [[commands.field]] id = "nodb" label = "Do not connect to a database" type = "boolean" option = ["--nodb"] sources = ["fig"] [[commands.field]] id = "norc" label = "Skip ~/.mongoshrc.js" type = "boolean" option = ["--norc"] sources = ["fig"] [[commands.task]] id = "connect" label = "Connect" fields = ["uri", "username", "auth_db"] required = ["uri"] [[commands.task]] id = "local" label = "Local shell" fields = ["port", "quiet"] required = [] [[commands.group]] id = "basic" label = "Basic" fields = ["uri", "port", "username", "auth_db", "eval"] [[commands.group]] id = "advanced" label = "Advanced" fields = ["shell", "tls", "quiet", "nodb", "norc"]