Node.js/Express RestAPIs CRUD – Sequelize ORM – PostgreSQL

Sequelize is a promise-based ORM for Node.js v4 and later. In the tutorial, we will show how to build Node.js/Express RestAPIs to interact with PostgreSQL using Sequelize CRUD.

Sequelize ORM

Sequelize is a promise-based Node.js ORM for Postgres, MySQL, SQLite and Microsoft SQL Server. It has many solid features for transaction, relations, read replication and more.

Now getting started with PostgreSQL ->


Set up Connection

Sequelize Model

Sequelize Queries

– Find All:

– Find by ID:

– Update a Customer:

– Delete a Customer:


We create a NodeJS/Express-Sequelize project as below structure:

nodejs-express-restapis-sequelize-postgresql + project structure

Setting up NodeJs/Express project

Following the guide to create a NodeJS/Express project.

Install Sequelize with PostgreSQL:

-> package.json file:

Setting up Sequelize PostgreSQL connection

– Create ./app/config/env.js file:

– Setup Sequelize-PostgreSQL connection in ./app/config/db.config.js file:

Create Sequelize model

Express RestAPIs

Define Customer’s routes in ./app/controller/customer.route.js file:


Implement Customer’s controller in ./app/controller/customer.controller.js file:


Run & Check results

Start Node.js server, Logs ->

Use Postman to check results ->

– Post request:

nodejs-express-restapis-sequelize-postgresql + post-request

-> Sequelize’s Insert Logs:

-> PostgreSQL records:

nodejs-express-restapis-sequelize-postgresql + postgresql-records

– Get requests:

nodejs-express-restapis-sequelize-postgresql + get-all-customer

nodejs-express-restapis-sequelize-postgresql + get-a-customer

– Put request:

nodejs-express-restapis-sequelize-postgresql + put-a-customer

– Delete request:

nodejs-express-restapis-sequelize-postgresql + delete-a-customer

-> Sequelize’s select, update, delete Logs:

-> final PostgreSQL’s records:

nodejs-express-restapis-sequelize-postgresql + final-postgresql-records



By grokonez | July 10, 2018.

Last updated on February 6, 2020.

Related Posts

1 thought on “Node.js/Express RestAPIs CRUD – Sequelize ORM – PostgreSQL”

  1. npm install found 2 high severity vulnerabilities

    If I force a fix, it break the application. What does this mean. Is there a fix?

Got Something To Say:

Your email address will not be published. Required fields are marked *