Socket
Socket
Sign inDemoInstall

mongodb-launcher

Package Overview
Dependencies
1
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    mongodb-launcher

A simple process launcher for creating test instance of mongodb to use in testing. Usually the reason you'll want to do this is to make sure your test databases are isolated from your default mongo instance so tests cannot destroy real data. It also allo


Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Install size
24.2 kB
Created
Weekly downloads
 

Readme

Source

mongodb-launcher

A simple process launcher for creating test instance of mongodb to use in testing. Usually the reason you'll want to do this is to make sure your test databases are isolated from your default mongo instance so tests cannot destroy real data. It also allows you to run your tests without assuming processes outside the test runner are already running.

Starting a mongo instance

You can start as many mongo instances as you need by passing different ports. If an instance is already running on that port, the start function will call back immediately.

var mongo = require('mongodb-launcher');

var args = {port:45000, dbPath: './testDb'};
var db;
mongo.start(function(err, _db) {
  if (err) {
    console.error(err);
    process.exit(1);
  }
  
  db = _db;
  console.log('Mongo instance alive on port', args.port);
});

Stopping a mongo instance

To stop a mongo instance, you can either call the stop method on the returned db intance, or call stop on the module, passing in the port of the instance you want to kill.

db.stop(function(err) {
  // ...
});

// OR

mongo.stop(45000, function(err) {
  // ...
});

Emitted events

FAQs

Last updated on 21 Apr 2014

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc