- Notifications
You must be signed in to change notification settings - Fork113
bezkoder/node-js-postgresql-crud-example
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
Full Article with implementation:
We will build Rest Apis that can create, retrieve, update, delete and find Tutorials by title.
The following table shows overview of the Rest APIs that will be exported:
- GET
api/tutorialsget all Tutorials - GET
api/tutorials/:idget Tutorial by id - POST
api/tutorialsadd new Tutorial - PUT
api/tutorials/:idupdate Tutorial by id - DELETE
api/tutorials/:idremove Tutorial by id - DELETE
api/tutorialsremove all Tutorials - GET
api/tutorials/publishedfind all published Tutorials - GET
api/tutorials?title=[kw]find all Tutorials which title contains 'kw'
Front-end that works well with this Back-end
Angular 8 /Angular 10 /Angular 11 /Angular 12 /Angular 13 /Angular 14 /Angular 15 /Angular 16
This is our Node.js PostgreSQL CRUD example using Express & Sequelize application demo, test Rest Apis with Postman.
Run our Node.js application with command:node server.js.
Using Postman, we're gonna test all the Apis above.
- Create a new Tutorial using
POST /tutorialsApi
After creating some new Tutorials, you can check PostgreSQL table:
id | title | description | published | createdAt | updatedAt----+-------------+-------------------+-----------+----------------------------+---------------------------- 1 | Node Tut #1 | Tut#1 Description | f | 2020-01-29 10:42:57.121+07 | 2020-01-29 10:42:57.121+07 2 | Node Tut #2 | Tut#2 Description | f | 2020-01-29 10:43:05.131+07 | 2020-01-29 10:43:05.131+07 3 | Node Tut #3 | Tut#3 Description | f | 2020-01-29 10:43:48.028+07 | 2020-01-29 10:43:48.028+07 4 | Js Tut #4 | Tut#4 Desc | f | 2020-01-29 10:45:40.016+07 | 2020-01-29 10:45:40.016+07 5 | Js Tut #5 | Tut#5 Desc | f | 2020-01-29 10:45:44.289+07 | 2020-01-29 10:45:44.289+07- Retrieve all Tutorials using
GET /tutorialsApi
- Retrieve a single Tutorial by id using
GET /tutorials/:idApi
- Update a Tutorial using
PUT /tutorials/:idApi
Checktutorials table after some rows were updated:
id | title | description | published | createdAt | updatedAt----+----------------+-------------------+-----------+----------------------------+---------------------------- 1 | Node Tut #1 | Tut#1 Description | f | 2020-01-29 10:42:57.121+07 | 2020-01-29 10:42:57.121+07 3 | Node Tut #3 | Tut#3 Description | f | 2020-01-29 10:43:48.028+07 | 2020-01-29 10:43:48.028+07 2 | Node Js Tut #2 | Tut#2 Description | t | 2020-01-29 10:43:05.131+07 | 2020-01-29 10:51:55.235+07 4 | Js Tut #4 | Tut#4 Desc | t | 2020-01-29 10:45:40.016+07 | 2020-01-29 10:54:17.468+07 5 | Js Tut #5 | Tut#5 Desc | t | 2020-01-29 10:45:44.289+07 | 2020-01-29 10:54:20.544+07- Find all Tutorials which title contains 'js':
GET /tutorials?title=js
- Find all published Tutorials using
GET /tutorials/publishedApi
- Delete a Tutorial using
DELETE /tutorials/:idApi
Tutorial with id=4 was removed fromtutorials table:
id | title | description | published | createdAt | updatedAt----+----------------+-------------------+-----------+----------------------------+---------------------------- 1 | Node Tut #1 | Tut#1 Description | f | 2020-01-29 10:42:57.121+07 | 2020-01-29 10:42:57.121+07 3 | Node Tut #3 | Tut#3 Description | f | 2020-01-29 10:43:48.028+07 | 2020-01-29 10:43:48.028+07 2 | Node Js Tut #2 | Tut#2 Description | t | 2020-01-29 10:43:05.131+07 | 2020-01-29 10:51:55.235+07 5 | Js Tut #5 | Tut#5 Desc | t | 2020-01-29 10:45:44.289+07 | 2020-01-29 10:54:20.544+07- Delete all Tutorials using
DELETE /tutorialsApi
Now there are no rows intutorials table:
id | title | description | published | createdAt | updatedAt----+-------+-------------+-----------+-----------+-----------For more detail, please visit:
Security:
Node.js JWT Authentication & Authorization with PostgreSQL example
Associations:
Fullstack:
Integration (run back-end & front-end on same server/port):
npm installnode server.jsAbout
Node.js PostgreSQL CRUD example with Express Rest APIs
Topics
Resources
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Releases
Packages0
Uh oh!
There was an error while loading.Please reload this page.








