Sequelize CRUD MariaDB example | Build CRUD Node.js/Express RestAPIs example

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

Related posts:

Sequelize ORM – Build CRUD RestAPIs with NodeJs/Express, Sequelize, MySQL
Angular 6 HttpClient – Upload Files/Download Files to MySQL with Node.js/Express RestAPIs – using Multer + Sequelize ORM
Angular 6 HttpClient Crud + Node.js Express Sequelize + MySQL – Get/Post/Put/Delete RestAPIs
NodeJS – GridFS APIs Upload/Download Files to MongoDB – Mongoose
Angular 6 Client – Upload Files/Download Files to PostgreSQL with SpringBoot RestAPIs example
Sequelize One-To-One association – NodeJS/Express, MySQL

Related pages:


Project Design

nodejs-express-rest-apis-post-get-put-delete-request-sequelize-crud-apis-mariadb + architecture-project

Sequelize ORM

Setup Connection

Sequelize Model

Sequelize Create/Queries

– Create Object:

– Find All:

– Find By ID:

– Update a Customer:

– Delete a Customer:


Create a NodeJS/Express-Sequelize project as below structure ->

nodejs-express-rest-apis-post-get-put-delete-request-sequelize-crud-apis-mariadb + nodejs-project-structure

Setup NodeJs/Express Project

Following the guide to create a NodeJS/Express project.
Install Sequelize & MySQL:

-> package.json file:

Setup Sequelize MariaDB Connection

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

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

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 ->

– POST customers ->

nodejs-express-rest-apis-post-get-put-delete-request-sequelize-crud-apis-mariadb + post-request

– GET all customers ->

nodejs-express-rest-apis-post-get-put-delete-request-sequelize-crud-apis-mariadb + get-all-request

– GET a customer by ID:

nodejs-express-rest-apis-post-get-put-delete-request-sequelize-crud-apis-mariadb + get-a-customer-by-id-request

– PUT a customer ->

nodejs-express-rest-apis-post-get-put-delete-request-sequelize-crud-apis-mariadb + put-a-customer-by-id

– DELETE a customer by ID ->

nodejs-express-rest-apis-post-get-put-delete-request-sequelize-crud-apis-mariadb + destroy-request

Sequelize’s Logs ->


How to work with the below sourcecode?

– Download the sourcecode -> We get a file
– Extract the zip file, then cd to folder Nodejs-Express-Sequelizejs-MariaDB.
– Install libs by commandline: npm install
– Start MariaDB
– Start Node.js server by cmd: npm start

Sourcecode ->


By grokonez | August 18, 2018.

Related Posts

2 thoughts on “Sequelize CRUD MariaDB example | Build CRUD Node.js/Express RestAPIs example”

Got Something To Say:

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