crud application using node and mongodb
What you will learn
- Curiosity, interest and a tiny bit knowledge of Node.js, also you need to have node installed on your system.
Not only SQL database or more popularly known as NoSQL database is a database design approach that provides a mechanism to store and access a wide variety of unstructured data. This unstructured data can contain a mixture of data models, including key-value, document, columnar and graph formats, etc. NoSQL database is especially useful for handling humongous sets of distributed data. These databases have a dynamic schema and no specific query language along with no or very fewer relationships. But it stores the data in the form of collections and documents which enable quick updates.
There is a list of NoSQL databases which are used quite heavily in the industry, some of which I have listed below:
- Amazon SimpleDB
To know more about NoSQL and it varies from SQL databases, you can check out this article on Differences between SQL & NoSQL Databases.
In this Node.js MongoDB tutorial, I will be focussing on only one of these databases, which by now you might have guessed, that is MongoDB. But before I show you how to work with it, let’s get familiar with its nitty-gritty.
ntroduction to MongoDB
MongoDB is an open source non-relational database that stores the data in the form of collections and documents. This kind of databases preserves most of the functionalities while offering horizontal scalability. This eases the work of a developer by providing persistence to the data and enhancing agility.
MongoDB stores the JSON documents in the form of collections having dynamic schemas. It stores all the related information together which enhances the speed of query processing. This way, it also helps in bringing down the gap between the key-value stores and relational databases.
Below I have listed down a few of the most intriguing features of MongoDB:
- Indexing: It makes use of indexes that helps in improving the search performance.
- Replication: MongoDB distributes the data across different machines.
- Ad-hoc Queries: It supports ad-hoc queries by indexing the BSON documents & using a unique query language.
- Schemaless: It enhances the flexibility of the data and needs no script to modify or update data.
- Sharding: It makes use of sharding which eases the deployment of very large data sets and provides high throughput operations.
Now that you are familiar with MongoDB, let’s move ahead with this Node.js MongoDB tutorial and see how simple it is to install MongoDB in the system.
Express is one of the most popular web frameworks for Node.js that supports routing, middleware, view system… Mongoose is a promise-based Node.js ODM for MongoDB that provides a straight-forward, schema-based solution to model our application data along with built-in type casting, validation, query building, business logic hooks… In this tutorial, I will show you step by step to build Node.js Restful API for CRUD operations using Express, Mongoose with MongoDB database.
Getting Started with CRUD
Folder Structer in vs code
Setting up MongoDB and routes