Full-Stack Web Development with Vue.js and Node

(singke) #1

3


Introducing MongoDB


The name MongoDB comes from the phrase huMONGOus data, meaning that it can handle


a lot of data. MongoDB is a document-oriented database architecture. It enables us to


develop faster and scale better. In relational database designs, we store data by creating
tables and rows, but with MongoDB, we can model our data as JSON documents, which is


much simpler compared to those relational databases. If we are agile and our requirements
keep changing very often, and if we need to do continuous deployment, then MongoDB is


our choice. Being a document-based data model, MongoDB is very flexible as well.


The biggest advantage of using MongoDB is that the data is unstructured. We can
customize our data in any format we like. In a relational database management system


(RDBMS), we have to define exactly the number of fields a table can have, but with
MongoDB, each document can have its own number of fields. We can add new data


without even having to worry about changing the schema, which is why Mongo has a


schemaless design model for the database.


If our business is growing fast, we need to scale faster, we need to access data in a more


flexible way, and if we need to make changes to our data without having to worry about
updating our application's database schemas, then MongoDB is the best choice for us.


Adding new columns to tables in RDBMS also creates some performance issues. But, since


MongoDB is schemaless, adding new fields is done in an instant without compromising the
performance of our application.


In a relational database, the terminologies that we use are database, tables, and rows,
whereas in MongoDB, we use database, collections, and documents, respectively.


Here is a brief summary of what we will be covering in this chapter:


Introducing to MongoDB and the benefits of using MongoDB
Understanding the MongoDB database, collections, and documents
Introducing to Mongoose, creating a connection with Mongoose, understanding
Mongoose, and CRUD operations with Mongoose
Adding default and custom validations with Mongoose
Free download pdf