Node.js MongoDB Driver

You use Node.js to write event-driven, scalable network programs in server-side JavaScript. Node.js runs on Google’s V8. This section describes the available tools and suggested practices for using Node.js with MongoDB. For a more detailed discussion, see the Node.js Driver Manual.

The following are the README and source code:

Node.js Driver

The MongoDB Node.js driver is the officially supported node.js driver for MongoDB. In Spring 2012, MongoDB officially adopted the popular Node MongoDB Native Project and sponsored the maintainer, Christian Kvalheim, to continue its development. It is written in pure JavaScript and provides a native asynchronous Node.js interface to MongoDB. The driver is optimized for simplicity. It can be used on its own, but it also serves as the basis of several object mapping libraries, such as Mongoose.

Install or Upgrade

The easiest way to install is to use npm:

npm install mongodb


supported. compatible. anything incompatible will be fixed: Supported
unsupported. minor incompatibilities may exist: Minor incompatibility
unsupported. incompatible: Unsupported

MongoDB Compatibility

        MongoDB Version
    2.4 2.6 3.0
  1.2.X Supported Minor incompatibility Minor incompatibility
  1.3.X Supported Minor incompatibility Minor incompatibility
  1.4.X Supported Supported Minor incompatibility
  >=1.4.29 Supported Supported Supported
Driver Version >=2.0.14 Supported Supported Supported

Language Compatibility

        Language Version
    v0.8.X v0.10.X v0.11.X unstable
  1.2.X Supported Supported Minor incompatibility
  1.3.X Supported Supported Minor incompatibility
  1.4.X Supported Supported Minor incompatibility
  >=1.4.18 Supported Supported Supported
Driver Version 2.0.X Supported Supported Supported

Object Mappers

Because MongoDB is so easy to use, the basic Node.js driver can be the best solution for many applications. However, if you need validations, associations, and other high-level data modeling functions, then an Object Document Mapper may be helpful.


Mongoose is an ODM for Node.js. It has a thriving open source community and includes advanced schema-based features such as async validation, casting, object life-cycle management, pseudo-joins, and rich query builder support.

Install it easily with npm:

npm install mongoose

The following are related resources:

Other Notable Projects

  • Mongoskin: Layer for node-mongodb-native.
  • Mongolia: Lightweight MongoDB ORM/driver wrapper.
  • Mongojs: Somewhat mimics the MongoDB shell api.
  • MongoSmash: Uses Harmony’s Object.observe().

Each of these projects build on top of the native Node.js driver, and so some knowledge of that is useful, especially if you work with a custom MongoDB configuration.

3rd Party Drivers

A few 3rd party drivers exist. While not officially supported, these drivers take a different approach that may be valuable given your needs.

  • node-mongodb <https://github.com/orlandov/node-mongodb>_: An asynchronous Node interface to MongoDB, written in C.
  • Mongolian DeadBeef: A Node.js driver that attempts to approximate the MongoDB shell.