Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

mongoose vs mongodb (nodejs modules/extensions), which better? and why?

I've just arrived to Node.js and see that there are many libs to use with the MongoDB, the most popular seem to be these two: (mongoose and mongodb). Can I get pros and cons of those extensions? Are there better alternatives to these two?

Edit: Found a new library that seems also interesting node-mongolian and is "Mongolian DeadBeef is an awesome Mongo DB node.js driver that attempts to closely approximate the mongodb shell." (readme.md)

https://github.com/marcello3d/node-mongolian

This is just to add more resources to new people that view this, so basically Mongolian its like an ODM...

like image 831
norman784 Avatar asked Feb 10 '12 18:02

norman784


People also ask

Is Mongoose better than MongoDB?

js applications to connect to MongoDB and work with data. On the other side Mongoose it other library build on top of mongoDB. It is more easier to understand and use. If you are a beginner than mongoose is better for you to work with.

What is the benefits of using Mongoose rather than just using MongoDB?

Mongoose vs MongoDB Node.js Driver: A Comparison The benefit of using Mongoose is that we have a schema to work against in our application code and an explicit relationship between our MongoDB documents and the Mongoose models within our application.

Is MongoDB better than Nodejs?

MongoDB is a widely used NoSQL database. The ability to store data in several formats makes MongoDB a beneficial tool for managing large amounts of data. On the other hand, Nodejs is a well-known runtime environment that assists in executing JavaScript code outside the browser.

What is the benefit to using Mongoose?

Advantages of Mongoose module:Collection validation of the MongoDB database can be done easily. Predefined Structure can be implemented on the collection. Constraints can be applied to documents of collections using Mongoose.


1 Answers

Mongoose is higher level and uses the MongoDB driver (it's a dependency, check the package.json), so you'll be using that either way given those options. The question you should be asking yourself is, "Do I want to use the raw driver, or do I need an object-document modeling tool?" If you're looking for an object modeling (ODM, a counterpart to ORMs from the SQL world) tool to skip some lower level work, you want Mongoose.

If you want a driver, because you intend to break a lot of rules that an ODM might enforce, go with MongoDB. If you want a fast driver, and can live with some missing features, give Mongolian DeadBeef a try: https://github.com/marcello3d/node-mongolian

like image 58
cjohn Avatar answered Oct 19 '22 12:10

cjohn