CRUDing with Mongoose

MongoDB features are great, but how do we use it in NodeJS? There are multiple libraries such as mongodb-native and mongoose. We are going to use the latter, because it provides validation, casting, and ORM.

Being schema-free could be handy at times; however, there are cases when we want to maintain the consistency of the data. Mongoose offers such an opportunity to enjoy both strict and loose schema. We are going to learn how to CRUD data on MongoDB through Mongoose.


Schemas are the way through which Mongoose provides data types and validations to the MongoDB documents.

We are going to do the examples in the NodeJS shell directly. Go to the meanshop folder and run node (and run mongod if you have not yet done so). Once ...

Get Web Application Development with MEAN now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.