We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 5 years ago.
Improve this questionThere are several MongoDB modules available for Node.js in the following link - https://github.com/joyent/node/wiki/modules#wiki-db-nosql-mongo
Please, suggest me one (I'd like to know why you choose that one?).
It depends on what level of abstraction you want from your data. If you want something similar to an ORM, then Mongoose is the obvious choice and is popular.
However, the node-mongodb-native driver gives you clean duplication of almost the entire MongoDB API and since BSON is translated to JSON and JavaScript is a flexible dynamic language, there's really no need for an ORM. The latter does have benefits such a defining a schema which helps with validation and other tasks, but it also limits your flexibility.
Mongoskin is built atop node-mongodb-native but gives you the ability to have additional JavaScript method bindings and deal with connections and cursors easier. It's pretty lightweight, so you can stick with the basics or do more. This library is my personal preference and our team has built our own tooling and validation system around it.
Mongoose is a popular choice. But the documentation is just as bad (if not worse) than the MongoDB docs.
I personally prefer Mongolian, it's the closest thing you get to the Mongo shell and it's straight forward to use.
My fork adds very simple collection initialization.
Mongoose doesn't support bulk insert and it is schema-based. When you try to create different schemas for same collection, it throws exception. Consider carefully its suitability to your case before start with it.
精彩评论