@mongosh/cli-repl
MongoDB Shell CLI REPL Package
Last updated 2 months ago by addaleax .
Apache-2.0 · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install @mongosh/cli-repl 
SYNC missed versions from official npm registry.

@mongosh/cli-repl Build Status

Evergreen Build

CLI interface for MongoDB Shell, an extension to Node.js REPL with MongoDB API.

Usage

  $ mongosh [options] [db address]

  Options:
    -h, --help                                 Show this usage information
        --ipv6                                 Enable IPv6 support (disabled by default)
        --host [arg]                           Server to connect to
        --port [arg]                           Port to connect to
        --version                              Show version information
        --shell                                Run the shell after executing files
        --nodb                                 Don't connect to mongod on startup - no 'db address' [arg] expected
        --norc                                 Will not run the '.mongorc.js' file on start up
        --eval [arg]                           Evaluate javascript
        --retryWrites                          Automatically retry write operations upon transient network errors
        --disableImplicitSessions              Do not automatically create and use implicit sessions

  Authentication Options:

    -u, --username [arg]                       Username for authentication
    -p, --password [arg]                       Password for authentication
        --authenticationDatabase [arg]         User source (defaults to dbname)
        --authenticationMechanism [arg]        Authentication mechanism
        --gssapiServiceName [arg] (=mongodb)   undefined
        --gssapiHostName [arg]                 Automatically retry write operations upon transient network errors

  TLS Options:

        --tls                                  Use TLS for all connections
        --tlsCertificateKeyFile [arg]          PEM certificate/key file for TLS
        --tlsCertificateKeyFilePassword [arg]  undefined
        --tlsCAFile [arg]                      Certificate Authority file for TLS
        --tlsCRLFile [arg]                     Certificate Revocation List file for TLS
        --tlsAllowInvalidHostnames             undefined
        --tlsAllowInvalidCertificates          undefined
        --tlsCertificateSelector [arg]         TLS Certificate in system store
        --tlsDisabledProtocols [arg]           Comma separated list of TLS protocols to disable [TLS1_0,TLS1_1,TLS1_2]

  FLE AWS Options

        --awsAccessKeyId [arg]                 AWS Access Key for FLE Amazon KMS
        --awsSecretAccessKey [arg]             AWS Secret Key for FLE Amazon KMS
        --awsSessionToken [arg]                Optional AWS Session Token ID
        --keyVaultNamespace [arg]              database.collection to store encrypted FLE parameters
        --kmsURL [arg]                         Test parameter to override the URL for

  DB Address Examples

        foo                                    Foo database on local machine
        192.168.0.5/foo                        Foo database on 192.168.0.5 machine
        192.168.0.5:9999/foo                   Foo database on 192.168.0.5 machine on port 9999
        mongodb://192.168.0.5:9999/foo         Connection string URI can also be used

  File Names

        A list of files to run. Files must end in .js and will exit after unless --shell is specified.

  Examples

        Start mongosh using 'ships' database on specified connection string:
        $ mongosh mongodb://192.168.0.5:9999/ships

  For more information on mongosh usage: https://docs.mongodb.com/manual/mongo/.

Log Format

CLI REPL listens to a few events via a message bus that are then logged to user's local log file in ~/.mongodb/mongosh/ in ndjson format using pino.

bus.on('mongosh:connect', connectEvent)

Where connectionInfo is an object with the following interface:

interface ConnectEvent {
  driverUri: string;
}

Used to log and send telemetry about connection information. Sensitive information is stripped beforehand.

Example:

bus.emit('mongosh:connect', {
  driverUri: 'mongodb://192.168.0.5:9999/ships' 
})

bus.on('mongosh:new-user', userID, enableTelemetry)

Where userID is a BSON ObjectID and enableTelemetry is a boolean flag. This is used for telemetry tracking when the user initially uses mongosh.

Example:

bus.emit('mongosh:new-user', '12394dfjvnaw3uw3erdf', true)

bus.on('mongosh:update-user', id, enableTelemetry)

Where userID is a BSON ObjectID and enableTelemetry is a boolean flag. This is used internally to update telemetry preferences and userID in the logger.

Example:

bus.emit('mongosh:update-user', '12394dfjvnaw3uw3erdf', false)

bus.on('mongosh:error', error)

Where error is an Error Object. Used to log and send telemetry about errors that are thrown.

Example:

bus.emit('mongosh:error', new Error('Unable to show collections'))

bus.on('mongosh:help')

Used when help command was used.

Example:

bus.emit('mongosh:help')

bus.on('mongosh:rewritten-async-input', inputInfo)

Used for internal debugging of async-rewriter. inputInfo is an object with the following interface:

interface AsyncRewriterEvent {
  original: string;
  rewritten: string;
}

Example:

bus.emit('mongosh:rewritten-async-input', {
  original: 'db.coll.find().forEach()',
  rewritten: 'await db.coll.find().forEach();'
})

bus.on('mongosh:use', args)

Used for recording information about use. args has the following interface:

interface UseEvent {
  db: string;
}

Example:

bus.emit('mongosh:use', { db: 'cats' })

bus.on('mongosh:show', args)

Used for recording information about show command. args has the following interface:

interface ShowEvent {
  method: string;
}

Example:

bus.emit('mongosh:show', { method: 'dbs' })

bus.on('mongosh:it')

Used for recording when it command was called.

Example:

bus.emit('mongosh:it')

bus.on('mongosh:api-call', args)

Used for recording information when API calls are made. args has the following interface:

interface ApiEvent {
  method?: string; 
  class?: string;
  db?: string;
  coll?: string;
  arguments?: ApiEventArguments;
}
interface ApiEventArguments {
  pipeline?: any[];
  query?: object;
  options?: object;
  filter?: object; 
}

arguments may contain information about the API call. As a rule, we don't emit information containing documents coming from API calls such as db.coll.insert() or db.coll.bulkWrite() to keep cleaner logs.

aggregate Event Example:

this.messageBus.emit('mongosh:api-call', {
  method: 'aggregate',
  class: 'Collection',
  db, coll, arguments: { options, pipeline }
});

runCommand Event Example:

this.messageBus.emit('mongosh:api-call', {
  method: 'runCommand', class: 'Database', db, arguments: { cmd }
});

createIndex Event Example:

this.messageBus.emit('mongosh:api-call', {
  method: 'createIndex',
  class: 'Collection',
  db, coll, arguments: { keys, options }
});

Local Development

Installation

npm install --save @mongosh/cli-repl

Current Tags

  • 0.6.1                                ...           latest (2 months ago)

35 Versions

  • 0.6.1                                ...           2 months ago
  • 0.6.0                                ...           2 months ago
  • 0.5.2                                ...           2 months ago
  • 0.5.1                                ...           2 months ago
  • 0.5.0                                ...           3 months ago
  • 0.4.2                                ...           4 months ago
  • 0.4.1                                ...           4 months ago
  • 0.4.0                                ...           4 months ago
  • 0.3.1                                ...           4 months ago
  • 0.3.0                                ...           4 months ago
  • 0.2.2                                ...           5 months ago
  • 0.2.1                                ...           5 months ago
  • 0.2.0                                ...           5 months ago
  • 0.1.0                                ...           6 months ago
  • 0.0.8                                ...           6 months ago
  • 0.0.7                                ...           7 months ago
  • 0.0.6                                ...           7 months ago
  • 0.0.5                                ...           8 months ago
  • 0.0.4                                ...           8 months ago
  • 0.0.3                                ...           8 months ago
  • 0.0.2-alpha.0                                ...           8 months ago
  • 0.0.1                                ...           8 months ago
  • 0.0.1-alpha.19                                ...           8 months ago
  • 0.0.1-alpha.18                                ...           8 months ago
  • 0.0.1-alpha.17                                ...           8 months ago
  • 0.0.1-alpha.15                                ...           8 months ago
  • 0.0.1-alpha.14                                ...           8 months ago
  • 0.0.1-alpha.13                                ...           9 months ago
  • 0.0.1-alpha.12                                ...           9 months ago
  • 0.0.1-alpha.11                                ...           9 months ago
  • 0.0.1-alpha.10                                ...           10 months ago
  • 0.0.1-alpha.6                                ...           10 months ago
  • 0.0.1-alpha.4                                ...           10 months ago
  • 0.0.1-alpha.3                                ...           10 months ago
  • 0.0.1-alpha.2                                ...           10 months ago

Copyright 2014 - 2016 © taobao.org |