An elegant guide to Sequelize and Node.js

Sequelize is a promise-based SQL ORM for Node.js, with support to Postgres, MySQL, MariaDB, SQLite, and Microsoft SQL!
During this tutorial, we will go through the creation of a simple library database using Sequelize and Node.js system.

What You Will Learn#

  • How to do CRUD SQL operations with Sequelize ✅

  • To create your own Sequelize models ✅

  • Use Sequelize to handle model relationships ✅


Create a model to represent our first table#

Models are the soul of Sequelize, we use them to represent the data of our tables, both on a row-level as a model instance, or as a table structure level as a model.
Let's create our first model to represent a book in our library.

But first using NPM we need to install the following libraries:

Let's create a db.js file, to initialize our Sequelize database connection