mongodb-runner
TypeScript icon, indicating that this package has built-in type declarations

5.7.1 • Public • Published

mongodb-runner

Helper for spinning up MongoDB servers and clusters for testing.

Example usage

Note: Version 5 of mongodb-runner is a full re-write. Many things work differently in version 5 and above.

$ npx mongodb-runner start -t sharded
$ npx mongodb-runner start -t replset -- --port 27017
$ npx mongodb-runner start -t replset -- --setParameter allowDiskUseByDefault=true
$ npx mongodb-runner stop --all
$ npx mongodb-runner exec -t standalone -- sh -c 'mongosh $MONGODB_URI'
$ npx mongodb-runner exec -t standalone -- --setParameter allowDiskUseByDefault=true -- sh -c 'mongosh $MONGODB_URI'

Options

mongodb-runner <command>

Commands:
  mongodb-runner start  Start a MongoDB instance
  mongodb-runner stop   Stop a MongoDB instance
  mongodb-runner ls     List currently running MongoDB instances
  mongodb-runner exec   Run a process with a MongoDB instance (as MONGODB_URI
                        env var)

Options:
  -t, --topology     Select a topology type
           [choices: "standalone", "replset", "sharded"] [default: "standalone"]
      --arbiters     number of arbiter nodes for each replica set       [number]
      --secondaries  number of secondaries for each replica set         [number]
      --shards       number of shards for sharded clusters              [number]
      --version      MongoDB server version to use                      [string]
      --logDir       Directory to store server log files in             [string]
      --binDir       Directory containing mongod/mongos binaries        [string]
      --tmpDir       Directory for temporary files    [string] [default: "/tmp"]
      --runnerDir    Directory for storing cluster metadata
                           [string] [default: "/home/addaleax/.mongodb/runner2"]
      --docker       Docker image name to run server instances under    [string]
      --id           ID to save the cluster metadata under              [string]
      --all          for `stop`: stop all clusters                     [boolean]
      --debug        Enable debug output                               [boolean]
      --help         Show help                                         [boolean]

Programmatic use

import { MongoCluster } from 'mongodb-runner';

const cluster = await MongoCluster.start({
  topology: 'standalone'
});

try {
  console.log(cluster.connectionString);
} finally {
  await cluster.close();
}

License

Apache 2.0

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
5.7.132,080latest

Version History

VersionDownloads (Last 7 Days)Published
5.7.132,080
5.7.0134
5.6.611
5.6.58,858
5.6.452
5.6.30
5.6.230
5.6.12
5.6.01
5.5.44
5.5.318
5.5.22
5.5.10
5.4.63
5.4.52
5.4.48
5.4.312
5.4.20
5.4.10
5.4.00
5.3.40
5.3.30
5.3.10
5.3.01
5.2.11
5.2.01
5.1.11
4.10.0141
4.9.032
4.8.334
4.8.20
4.8.13,687
4.8.019
4.7.55
4.7.41
4.7.31
4.7.23
4.7.11
4.7.02
4.6.00
4.5.00
4.3.31
4.4.00
4.3.25
4.3.10
4.3.00
4.2.13
4.2.00
4.1.00
4.0.03
3.6.115
3.6.01
3.5.00
3.4.00
3.3.30
3.3.20
3.3.10
3.3.03
3.2.21
3.2.12
3.2.00
3.1.182
3.1.170
3.1.163
3.1.150
3.1.140
3.1.130
3.1.120
3.1.114
3.1.100
3.1.92
3.1.80
3.1.73
3.1.61
3.1.50
3.1.40
3.1.30
3.1.21
3.1.10
3.1.00
3.0.01
2.2.03
2.1.11
2.1.01
2.0.31
2.0.20
2.0.10
2.0.00
1.2.41
1.2.31
1.2.21
1.2.11
1.1.50
1.1.40
1.1.31
1.1.20
1.1.11
1.1.00
1.0.00
0.0.51
0.0.41
0.0.34
0.0.21
0.0.11

Package Sidebar

Install

npm i mongodb-runner

Weekly Downloads

45,218

Version

5.7.1

License

Apache-2.0

Unpacked Size

85.1 kB

Total Files

33

Last publish

Collaborators

  • mongodb-js-user
  • rueckstiess
  • durran
  • alexander_schroll
  • mabaasit
  • lerouxb
  • fredtruman
  • mbroadst
  • hswolff
  • satyasinha
  • matt_d_rat
  • rhysm
  • tomhollander
  • alena.khineika
  • jeff-allen-mongo
  • mmarcon
  • jonathan.balsano
  • mongodb-build
  • jack.weir
  • mcasimir
  • kristina.stefano
  • jarjee
  • shaketbaby
  • devtoolsbot
  • addaleax
  • gribnoysup
  • mutukrish
  • mongo-j
  • orechova
  • himanshusinghs
  • c-buckingham
  • nbbeeken
  • dbx-node
  • nirinchev
  • pearsb1
  • tylerbrock
  • imlucas
  • cilix
  • kangas
  • micheal.parks
  • machyne
  • schwartzrw
  • i80and
  • kay-kim
  • glowe
  • dpercy
  • redondos