Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
98 views72 pages

CRUD Express MysqlDB

The document provides steps to connect a Node.js application to a MySQL database and perform CRUD operations. It includes instructions on installing software requirements like Xampp and Visual Studio Code, creating a database and table, connecting to the database from a Node.js app, and implementing CRUD functionality through routes to add, fetch, edit, and delete records. Code examples and explanations are provided for each step in both JavaScript and HTML.

Uploaded by

Rohit Kumarr
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
98 views72 pages

CRUD Express MysqlDB

The document provides steps to connect a Node.js application to a MySQL database and perform CRUD operations. It includes instructions on installing software requirements like Xampp and Visual Studio Code, creating a database and table, connecting to the database from a Node.js app, and implementing CRUD functionality through routes to add, fetch, edit, and delete records. Code examples and explanations are provided for each step in both JavaScript and HTML.

Uploaded by

Rohit Kumarr
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 72

Node JS Mysql

CRUD

#Node JS Notes
Database Part

Akash Technolabs www.akashsir.com

3
Software Requirement
 Xampp
 https://www.apachefriends.org/download.html

 Visual Studio Code

Akash Technolabs www.akashsir.com


4
Open Xampp and
Start Apache and Mysql Service
C:/xampp/xampp-control.exe

Akash Technolabs www.akashsir.com


5
Create Database

Akash Technolabs www.akashsir.com


6
Create Table

Akash Technolabs www.akashsir.com


7
Create tbl_user table

Akash Technolabs www.akashsir.com


8
Specify Field Names

Akash Technolabs www.akashsir.com


9
Specify Field Name and Save Table

Akash Technolabs www.akashsir.com


10
Table Created

Akash Technolabs www.akashsir.com


11
Browse Data

Akash Technolabs www.akashsir.com


12
Express Installation

Akash Technolabs www.akashsir.com

13
Navigate to D Drive

Akash Technolabs www.akashsir.com


14
Download Express Generator

Akash Technolabs www.akashsir.com


15
Download Completed

Akash Technolabs www.akashsir.com


16
Create New Express Project

Akash Technolabs www.akashsir.com


17
Project Created Sucessfully

Akash Technolabs www.akashsir.com


18
Navigate to Project Folder

Akash Technolabs www.akashsir.com


19
Download Dependency

Akash Technolabs www.akashsir.com


20
Completed

Akash Technolabs www.akashsir.com


21
Open Visual Studio Code

Akash Technolabs www.akashsir.com


22
Open Project Folder

Akash Technolabs www.akashsir.com


23
Project Loaded

Akash Technolabs www.akashsir.com


24
Install Nodemon

Akash Technolabs www.akashsir.com


25
Nodemon Installed

Akash Technolabs www.akashsir.com


26
Run Project Using “nodemon”

Akash Technolabs www.akashsir.com


27
Open URL http://127.0.0.1:3000

Akash Technolabs www.akashsir.com


28
Database Connectivity

Akash Technolabs www.akashsir.com

29
Mysql Package
 https://www.npmjs.com/package/mysql

Akash Technolabs www.akashsir.com


30
Package

Akash Technolabs www.akashsir.com


31
Install Mysql Dependency

Akash Technolabs www.akashsir.com


32
Open Index.js Route

Akash Technolabs www.akashsir.com


33
Load Mysql Module

Akash Technolabs www.akashsir.com


34
Database Connection Code

Akash Technolabs www.akashsir.com


35
Check Database is Connected or Not

Akash Technolabs www.akashsir.com


36
Add Record

Akash Technolabs www.akashsir.com

37
Create New View -> add-form.ejs

Akash Technolabs www.akashsir.com


38
Write HTML Code in Add-form.ejs

Akash Technolabs www.akashsir.com


39
Conti..

Akash Technolabs www.akashsir.com


40
Render form in Routes

Akash Technolabs www.akashsir.com


41
Open url to View the Form

Akash Technolabs www.akashsir.com


42
Insert Form Query Code

Table Field Name

Textbox Name

Akash Technolabs www.akashsir.com


43
Test Form Code

Akash Technolabs www.akashsir.com


44
Record Added 
 Check your Table in phpmyadmin

Akash Technolabs www.akashsir.com


45
Fetch Data

Akash Technolabs www.akashsir.com

46
Fetch Data and Render in View

Data will be stored in


db_rows

Pass Data Array in


display-table.ejs

Akash Technolabs www.akashsir.com


47
Create display-table.ejs

Akash Technolabs www.akashsir.com


48
Write Fetch Data Code

Pass ID as Parameter in
Different Routes
EDIT | Delete | Show

Akash Technolabs www.akashsir.com


49
Test Data

Akash Technolabs www.akashsir.com


50
Delete

Akash Technolabs www.akashsir.com

51
Delete Code

Get Value From Parameter


(ID)

Akash Technolabs www.akashsir.com


52
Show

Akash Technolabs www.akashsir.com

53
Fetch Single Record Using Parameter

Akash Technolabs www.akashsir.com


54
Create Show.ejs View

Akash Technolabs www.akashsir.com


55
Show Record Code
Only Single Array Data will be Fetched

Akash Technolabs www.akashsir.com


56
Test Data

Akash Technolabs www.akashsir.com


57
Test Single Record

Akash Technolabs www.akashsir.com


58
Edit Record

Akash Technolabs www.akashsir.com

59
Fetch ID Wise Single Record

Akash Technolabs www.akashsir.com


60
Create Edit Form View File

Akash Technolabs www.akashsir.com


61
Write Edit form code

Akash Technolabs www.akashsir.com


62
Update Code Logic

Akash Technolabs www.akashsir.com


63
Test Record

Akash Technolabs www.akashsir.com


64
Change Data

Akash Technolabs www.akashsir.com


65
Update Record

Akash Technolabs www.akashsir.com


66
View Updated Record

Akash Technolabs www.akashsir.com


67
Enjoy 

Akash Technolabs www.akashsir.com

68
Get Exclusive
Video Tutorials

www.aptutorials.com
https://www.youtube.com/user/Akashtips
www.akashsir.com
Rating Us Now

Just Dial
https://www.justdial.com/Ahmedabad/Akash-Technolabs-
Navrangpura-Bus-Stop-Navrangpura/079PXX79-XX79-
170615221520-S5C4_BZDET

Sulekha
https://www.sulekha.com/akash-technolabs-navrangpura-
ahmedabad-contact-address/ahmedabad
Connect With Me
# Social Info

Akash.padhiyar
Akashpadhiyar
Akash Padhiyar
#AkashSir Akash_padhiyar

+91 99786-21654

www.akashsir.com
www.akashtechnolabs.com #Akashpadhiyar
www.akashpadhiyar.com #aptutorials
www.aptutorials.com

You might also like