mongobox.js
Start and stop a sandboxed instance of MongoDB from within a node.js application. Extremely useful for unit tests and no mocks of database required. The sandboxed MongoDB instance will run on a free port alongside other instances and will create files in a temporary directory that will be removed after the process exits.
var MongoBox = MongoBox; var options = {};var mongobox = options; mongoboxstart { if err return console; mongobox;};
Constructor options are:
databasePath
- temporary path for the database files. Will be created if it does not exist. By default a random temporary directory will be created.mongodBinary
- location of themongod
binary. By default the one from systemPATH
is used.port
- port to use. By default a random free port will be chosen.auth
-mongod
's--auth
command line value.scripting
- removesmongod
's--noscripting
enabled by default.prealloc
- removesmongod
's--noprealloc
enabled by default.
var mongobox = port:1337 databasePath: '/tmp/foobar';