Sequalize
Introduction

It is an object-relational mapping library that it does all sql command behind the scene to map the database table to the javascript object without writing sql command, but do database operation with help of helper function

In general, It is needed to create a modal that maps to database table , and create the instance based on that, so that new record will be added into table
It is also allowed to execute function to perform CRUD operation, but also can check the association between the table
Connect to mysql
// The connection is still established by using mysql2 library behind the scene
const Sequelize = require('sequelize');
const sequelize = new Sequelize('node-complete', 'root', 'nodecomplete', {
dialect: 'mysql',
host: 'localhost'
});
module.exports = sequelize;Modal Definition
Define the modal where the type should be matched with table schema
Create table
CRUD Operation
Associations
Create the relationship between tables by creating foreign key automatically
Last updated
Was this helpful?