Coder Social home page Coder Social logo

mongodb-prebuilt's Introduction

mongodb-prebuilt

badge

Install mongodb prebuilt binaries for command-line use using npm. This module helps you easily install the mongodb command for use on the command line without having to compile anything.

MongoDB is an open-source, document database designed for ease of development and scaling.

Installation

Download and install the latest build of mongodb for your OS and add it to your projects package.json as a devDependency:

npm install mongodb-prebuilt --save-dev

You can also use the -g flag (global) to symlink it into your PATH:

npm install -g mongodb-prebuilt

If that command fails with an EACCESS error you may have to run it again with sudo:

sudo npm install -g mongodb-prebuilt

Now you can just run mongod to run mongodb:

mongod

Complete list of programs:

About

Works on Mac, Windows, Linux and Solaris OSes that MongoDB supports.

The version numbers of this module DO NOT match the version number of the offical MongoDB releases. By default, latest production release will be selected. Different version is set via mongodb-version option:

npm install --mongodb-version=3.0.2 mongodb-prebuilt

Programmatic usage

var mongodb_prebuilt = require('mongodb-prebuilt');

mongodb_prebuilt.start_server({}, function(err) {
	if (err) {
		console.log('mongod didnt start:', err);
	} else {
		console.log('mongod is started');
	}
});

start_server(opts, callback)

opts

Type: object

Hash of options.

callback(err)

Type: function

Function called when the mongod is started or returned an error

Options

version

Type: string

Optional version of MongoDB can be specified, if it doesn't match latest version, and it is a first time you are running this version, mongodb-prebuilt will have to go through intall process first.

mongodb_prebuilt.start_server({
	version: "3.0.4"
}, function(err) {
	if (!err) console.log('server started');
});

args

Type: function

Optional arguments that are going to be passed to mongod, if argument doesn't have a value, set that value to true. To see complete list of supported arguments for your version run:

mongod --help

example of start_server with arguments

mongodb_prebuilt.start_server({
		args: {
			port: 27017,
			quiet: true
		}
})

logs_callback(buffer)

Type: function

Optional logs handler.

mongodb_prebuilt.start_server({
	logs_callback: logs_callback
}, function(err) {});

function logs_callback(buffer) {
	console.log("log message:", buffer.toString());
}

auto_shutdown

Type: boolean Default: false

Will automatically shutdown the mongodb server when the parent process either exits or throws an uncaught exception

Logging

To see logs in stdout, set environment variable DEBUG to mongodb

*nix

export DEBUG=mongodb
// without export
DEBUG=mongodb node myapp.js

windows

set DEBUG=mongodb

mongodb-prebuilt's People

Contributors

fracmak avatar pgaubatz avatar winfinit avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.