[confluence] MongoDB > Node.js

9 views
Skip to first unread message

nor...@mongodb.onconfluence.com

unread,
Jan 23, 2013, 2:43:00 PM1/23/13
to mongodb...@googlegroups.com

Node.js

Page edited by Francesca Krihely


Changes (1)

...
* [An introduction to the mongo node.js driver|https://www.10gen.com/presentation/mongohamburg-2011/an-introduction-nodejs-mongodb-driver] - June 2011
* [Using MongoDB with node.js|https://www.10gen.com/presentation/mongodc-2011/using-mongodb-with-nodejs] - June 2011
* [Node.js & MongoDB|http://www.10gen.com/webinars/nodejs] MongoDB|http://www.10gen.com/presentations/webinar/node.js-and-mongodb-a-panel-discussion] - Webinar June 2011
* [A beautiful marriage: MongoDB and node.js|http://www.10gen.com/presentation/mongonyc-2011/mongodb-and-nodejs] - MongoNYC June 2011
* [Rapid Realtime App Development with Node.JS & MongoDB|http://www.10gen.com/presentation/mongosf2011/nodejs] - MongoSF May 2011
...

Full Content

Node.js is used to write event-driven, scalable network programs in server-side JavaScript. It is similar in purpose to Twisted, EventMachine, etc. It runs on Google's V8.

This is an overview of the available tools and suggested practices for using Node.js with MongoDB. Those wishing to skip to more detailed discussion should check out the The Node.js Driver Manual.

Node.js Driver

The MongoDB Node.js driver is the 10gen-supported driver for MongoDB. In spring 2012 10gen officially adopted the popular Node MongoDB Native Project and sponsored the maintainer, Christian Kvalheim, to continue its development. It's written in pure javascript and provides a native asyncronous 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.

Installing / Upgrading

The easiest way to install is to use npm:

$ npm install mongodb

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

Mongoose is the 10gen-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

Other notable projects

  • Mongoskin - The future layer for node-mongodb-native.
  • Mongolia - Lightweight MongoDB ORM/Driver Wrapper.
  • Mongojs - Somewhat mimics the MongoDB shell api.

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 Mongo configuration.

Presentations

Tutorials

Mongoskin tutorial
Mongoose Tutorial

3rd Party Drivers

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

  • node-mongodb - Async Node interface to MongoDB (written in C)
  • Mongolian DeadBeef - A node.js driver that attempts to closely approximate the MongoDB shell.
Reply all
Reply to author
Forward
0 new messages