O'Reilly logo

Web Application Development with MEAN by Robert Onodi, Adrian Mejia, Amos Q. Haviv

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required