CRUD is an acronym that stands for Create, Read, Update and Delete. It refers to the operations implemented by databases. The NoSQL database MongoDB has these operations to create, read, update and delete documents.
Create Operations: This operation is used to add a new document to a collection. The document can be newly created or inserted into an existing one. If there is no existing collection, then the insert operation creates a new collection. Insert operation basically targets a single collection. The method of inserting document into a collection in MongoDB is -
Read Operations: This operation is used to retrieve a document from a collection. We can set query filters to identify a specific document. The method of retrieving documents from a collection in MongoDB is -
Update Operations: This operation is used to modify an existing document in a collection. Update operation basically targets a single collection. We can specify criteria or filters to identify the specific document to update. The method of updating documents from a collection in MongoDB is -
Delete Operations: This operation deletes or removes a document from a collection. Delete operation basically targets a single collection. We can specify criteria or filters to identify the specific document to delete. The method of deleting documents from a collection in MongoDB is -
Mongoose is an object data modeling(ODM) library for MongoDB and Nodejs. It is used to manage relationships between data and translate between objects in code and the representation of the objects in MongoDB. It provides schema validation as MongoDB is a schema-less NoSQL database. Everything starts with a schema in Mongoose and each schema maps to a MongoDB collection and the shape of the document is defined within that collection. Example of defining schema in Mongoose:
Express is a Node js web application framework that is equally flexible and minimal. It provides robust set of features for web and mobile applications. It provides a thin layer of features that is based on web application, without obscuring Nodejs features.