Nodejs mongodb driver comparison

node-mongodb-native

One of the most powerful Mongo drivers is node-mongodb-native. Most other drivers build
on top of it, including mongoskin. Unfortunately, it has an awkward interface with too many
callbacks. Also, mongoskin provides helper method bindings on Collection instances.

mongoose

Mongoose provides a full blown ORM view of Collections and Models,
and you are required to define a schema first. But why does mongodb need a schema?
If you're like me, then you prefer to drive your schema from the application layer,
and use fields without having had to define them beforehand.

Mongoose also provides a data abstraction layer with validation support. Again, if you're like me, then
you would prefer a lighter weight solution and to craft your own validation. I think this is the tao of mongodb.

mongoskin

Mongoskin is an easy to use driver of mongodb for nodejs,
it is similar with mongo shell, powerful like node-mongodb-native,
and supports binding helper methods to Collections.

Easier cursor

MVC helpers

You can bind additional methods for collection.
It is very useful if you want to use MVC patterns with nodejs and mongodb.
You can also invoke collection by properties after bind,
it could simplfy your require.

To keep your code in line with DRY principles, it's possible to create your own
data layer by for example, setting up your own validators and/or default values
inside the MVC methods as shown below in the config example

open(callback)

collection(collectionName)

bind(collectionName)

bind(collectionName, SkinCollection)

bind(collectionName, extendObject1, extendObject2 ...)

Bind SkinCollection to db properties as a shortcut to db.collection(name).
You can also bind additional methods to the SkinCollection, it is useful when
you want to reuse a complex operation. This will also affect
db.collection(name) method.

findAndModify(query, sort, update, options, callback)

/** Fetch and update a collection query: a filter for the query sort: if multiple docs match, choose the first one in the specified sort order as the object to manipulate update: an object describing the modifications to the documents selected by the query options: remove: set to a true to remove the object before returning new: set to true if you want to return the modified object rather than the original. Ignored for remove. upsert: true/false (perform upsert operation)**/

group(keys, condition, initial, reduce, command, callback)

count(query, callback)

distinct(key, query, callback)

Inserting

insert(docs, options, callback)

Updating

save(doc, options, callback)

/** Update a single document in this collection. spec - a associcated array containing the fields that need to be present in the document for the update to succeed document - an associated array with the fields to be updated or in the case of a upsert operation the fields to be inserted. Options: upsert - true/false (perform upsert operation) multi - true/false (update all documents matching spec) strict - true/false (perform check if the operation failed, required extra call to db) Deprecated Options: safe - true/false (perform check if the operation failed, required extra call to db)**/

License

(The MIT License)

Copyright (c) 2011 - 2012 kissjs.org

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
'Software'), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.