The difference between MongoDB and Mongoose

I wanted to use the mongodb database, but I noticed that there are two different databases with their own site and installation methods: mongodb and mongoose. So I got up, asking myself this question: β€œWhich one do I use?”.

So, to answer this question, I ask the community, can you explain what are the differences between the two? And the pros and cons if possible? Because they really are very similar to me.

+98
mongodb mongoose
Feb 25 '15 at 6:01
source share
7 answers

I assume that you already know that MongoDB is a NoSQL database system that stores data in the form of BSON documents. Your question, however, is about packages for Node.js.

From the point of view of Node.js, mongodb is a native driver for interacting with a mongodb instance, and mongoose is a tool for modeling objects for MongoDB.

Mongoose is built on top of the MongoDB driver to enable programmers to model their data.

EDIT: I don't want to comment on which is better, as that would make this answer self-confident. However, I will list some advantages and disadvantages of using both approaches.

Using Mongoose, a user can define a schema for documents in a specific collection. This provides great convenience in creating and managing data in MongoDB. On the other hand, the study of mongoose can take some time, and has some limitations in working with schemes, which are quite complex.

However, if your collection scheme is unpredictable, or you want to use a wrapper like Mongo in Node.js, then use the MongoDB driver. This is easiest to pick up. The disadvantage here is that you will have to write large amounts of code to verify the data, and the risk of errors is higher.

+158
Feb 25 '15 at 6:06
source share

Mongo is a NoSQL database.

If you do not want to use ORM for your data models, you can also use the mongo.js native driver: https://github.com/mongodb/node-mongodb-native .

Mongoose is one of those that provides us with the functionality to access Mongo data with easy-to-understand queries.

Mongoose plays the role of an abstraction over your database model.

+34
Feb 25 '15 at 6:35
source share

Another difference that I found with respect to both is that with the mongodb native driver it’s easy enough to connect to multiple databases , while you need to use work arounds in mongoose , which still have some disadvantages.

So, if you want to go for a multitasking application, go for the mongodb native driver.

+10
Nov 19 '15 at 12:51
source share

Mongodb and Mongoose are two different drivers for interacting with the MongoDB database.

Mongoose : Object Data Modeling (ODM) library that provides a rigorous modeling environment for your data. Used to interact with MongoDB, makes life easier, providing convenience in data management.

Mongodb : native driver in Node.js for interacting with MongoDB.

+3
Jun 26 '18 at 16:37
source share

If you plan to use these components with a proprietary code, please refer to the information below.

MongoDB:

  1. This is a database.
  2. This component is governed by the Affero General Public License (AGPL).
  3. If you associate this component with your proprietary code, then you should publish all the source code in the public domain due to its viral effect, such as (GPL, LGPL, etc.)
  4. If you place your application in the cloud, then it applies (2), and you also need to provide installation information to end users.

Mongoose:

  1. This is a tool for modeling objects.
  2. This component is regulated by the MIT license.
  3. It is allowed to use this component with proprietary code without any restrictions.
  4. Application delivery using any media or host is allowed.
+3
Oct 11 '18 at 6:07
source share

mongo-db is probably not a mongo-db choice for new developers.
On the other hand, mongoose as an ORM (Object Relational Mapping) may be the best choice for beginners.

+2
Apr 6 '19 at 10:41
source share

Mongodb and Mongoose are two completely different things!

Mongodb is the base itself and Mongoose is an object modeling tool for Mongodb

EDIT: As indicated, MongoDB is an npm package, thanks!

+1
Feb 25 '15 at 6:03
source share



All Articles