Node.js RestAPIs Express Mysql Example - Sequelize ORM Queries [Debug Mode]

Опубликовано: 09 Апрель 2026
на канале: loizenai
275
4

Node js Express Mysql Example - Sequelize ORM Queries [Debug Mode]

#nodejs #express #mysql #sequelizequery
#nodejsexamples #nodejsexpressexample #nodejsmysqlsequelize

Link tutorial: https://loizenai.com/tutorial-nodejs-...

In the tutorial, I will introduce step by step how to create a Nodejs RestAPIs and MySQL database with a full-stack technologies: Express RestAPI Framework (Cors + Body-Parse) + Sequelize ORM + MySQL.

To handling all POST/GET/PUT/DELETE RestAPI requests and do CRUD with MySQL database, we create a backend web Node.js application with 4 main points:

To handle RestAPI requests with Node.js, We use Express framework.
To do CRUD operations with MySQL database, We use Sequelize ORM.
We define all RestAPI URLs in router.js.
We implement how to process each RestAPI request in controller.js file.

After the tutorial, we will understand overall architecture and clearly picture how to create a full backend web restapis application with Node.js technology from abstract overview to specific helpful frameworks and details sourcecode for connecting all things in one application.

We will define 8 RestAPIs with POST/GET/PUT/DELETE methods for posting, fetching, updating, removing, pagination, filtering and sorting data from MySQL database:

– For normally requests with POST/GET/PUT/DELETE methods, we create a first GROUP with 5 RestAPIs:

1. a POST RestAPI /api/customers/create will handle the submit data from client to save in MySQL database
2. a GET RestAPI /api/customers/all will fetch all data from MySQL
3. a GET RestAPI /api/customers/onebyid/:id will get a single data by primary key id
4. a PUT RestAPI /api/customers/update/:id will update an existed record in MySQL
5. a DELETE RestAPI /api/customers/delete/:id will delete an existed record in MySQL which is associated with a primary key id

– For advanced purpose such as Filtering, pagination and Sorting, we create the second RestAPIs group:

1. Filtering Request – a GET RestAPI /api/customers/filteringbyage is used to fetch all records from MySQL with a filtering by age
2. Pagination Request – a GET RestAPI /api/customers/pagination is used to fetch data from MySQL with pagination purpose.
3. Pagination Filtering and Sorting – a GET RestAPI /api/customers/pagefiltersort is defined to fetch data from MySQL with pagination, filtering by age and ordering by 2 fields firstname and lastname

Structure of Video:
0:1 Introduce Overview Architecture and Goal
0:42 Download Sourcecode Nodejs Express RestAPIs
1:16 Install Need Nodejs Dependencies
1:25 Import Nodejs project to Visual Studio Code
1:34 Begin Introduce Nodejs Project Structure
1:35 env.js file for configure MySQL database
1:37 db.config.js file for configure MySQL with Sequelize ORM
1:45 router.js file for express define REstAPIs endpoint
1:51 Customer.model.js file
1:59 controller.js file for implement bussiness logic to handle Request with Sequelize Queries
2:09 introduce server.js file for creating Express server
2:18 start DEBUG
2:29 Start MYSQL database to check tables customers creating by NODEJS application
2:46 DEBUG with POST request - Creating a CUSTOMER via POST API with Postman
3:55 Start DEBUG Coding with GET request - get all customers from MySQL database
5:05 Start filtering all customer from mysql database with age= 23
5:50 Start getting a single Customer from MySQL database via a given id with GET REstAPI
6:24 Start updating a Customer from MYSQL database with PUT request
7:21 Start Delete a customer from MySQL database with DELETE request
7:57 Start Pagination restapi request with limit & page queries parameters
9:11 Start Pagination and Filtering and Sorting request with 3 queries parameters: limit, page and age

Related posts:
1. Angular Nodejs Fullstack CRUD Application with MySQL/PostgreSQL – Angular 10-9-8 HttpClient + Nodejs Express, Sequelize ORM
https://loizenai.com/angular-nodejs-f...

2. Nodejs JWT Authentication Example – Express RestAPIs + JSON Web Token + BCryptjs + Sequelize + MySQL/PostgreSQL
https://loizenai.com/nodejs-jwt-authe...

3. Nodejs RestAPIs Upload Download Multiple Excel Files to MySQL/PostgreSQL – Multer, Sequelize ORM, Exceljs, Read-excel-file
https://loizenai.com/nodejs-restapis-...

**Sourcecode**
Link: https://loizenai.com/tutorial-nodejs-...

@Copyright by https://loizenai.com
Email: [email protected]