CRUDing with Mongoose
MongoDB features are great, but how do we use it in NodeJS? There are multiple libraries such as
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 ...