- MongoDB Drivers >
- Node.js MongoDB Driver
Node.js MongoDB Driver¶
The following are the README and source code:
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 the officially supported 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.