The Mongoose and NodeJs History
In this article we hope to explain some of the history behind NodeJS, MongoDB, Mongoose, and how they became a common architecture among web developers.
Birth of NodeJS
Ryan Dahl took the V8 engine out of the chrome browser to a server. Then, nodejs was born. Now the developers had one language, both on the client-side as well as the server-side.
Why nodejs became so much popular?
Why? There are quite a few reasons for its popularity.
With nodejs, a new package manager also came out. We call it, Node Package Manager or NPM. It contains over 100,000 modules. It is very easy to use. You’ll commonly see packages installed with a simple line of code such as
npm install mongoose. This is all you need to do to install the mongoose package, it’s that simple. It manages all the dependencies that mongoose itself needs behind the scenes.
And there are few more reasons, but I will focus on the important one that is in the scope of this article, MongoDB. MongoDB is commonly used with Nodejs. MongoDB is a NoSQL database, and one of the most popular one. Also developers may prefer he schema-less structure to the rigidity of SQL databases, but each developer has his own preference.
MongoDB and mongoose
As the popularity of nodejs increased, new web application building stack, MEAN and MERN stack came out. In both of these, M and N stand for MongoDB and NodeJS, respectively. Using MongoDB is fairly easy when compared with Nodejs. But using MongoDB with Nodejs has one problem, abstraction failure. MongoDB is a schema-less database and the developers who came from SQL to MongoDB felt very uncomfortable working with dynamic collections of MongoDB that had no properly defined structure. This is where mongoose came into play and had a huge impact.
Mongoose is an Object Modelling Library(ODM). It is heavily used with nodejs when the database is implemented in MongoDB. One main advantage it provided was an abstraction. Now, the developers can define schema using mongoose. It overcame the one main problem. Moreover, MongoDB methods can easily be used in mongoose. Another important feature of mongoose is validations. Several other features such as plugins, middleware, population, etc came with it.
Today, the mongoose is an important library that is used heavily with Nodejs and MongoDB.
We hope this brief overview of some of the history behind NodeJS, MongoDB, and mongoose brought some insight into why these technologies are so popular. Thank you for reading another ObjectRocket knowledge base article!
Pilot the ObjectRocket Platform Free!
Try Fully-Managed CockroachDB, Elasticsearch, MongoDB, PostgreSQL (Beta) or Redis.Get Started