Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Node.js Postgresql Crud example - Restful CRUD API with Express, Sequelize and PostgreSQL example

NotificationsYou must be signed in to change notification settings

bezkoder/node-express-sequelize-postgresql

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

For instruction, please visit:

Node.js CRUD Rest APIs with Express, Sequelize & PostgreSQL example

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:

  • GETapi/tutorials get all Tutorials
  • GETapi/tutorials/:id get Tutorial by id
  • POSTapi/tutorials add new Tutorial
  • PUTapi/tutorials/:id update Tutorial by id
  • DELETEapi/tutorials/:id remove Tutorial by id
  • DELETEapi/tutorials remove all Tutorials
  • GETapi/tutorials/published find all published Tutorials
  • GETapi/tutorials?title=[kw] find all Tutorials which title contains 'kw'

Front-end that works well with this Back-end

Axios Client

Angular 8 /Angular 10 /Angular 11 /Angular 12 /Angular 13 /Angular 14 /Angular 15 /Angular 16 /Angular 17

Vue 2 Client /Vue 3 Client /Vuetify Client

React Client /React Redux Client

Demo Video

This is our Node.js PostgreSQL CRUD example using Express & Sequelize application demo, test Rest Apis with Postman.

Node.js PostgreSQL CRUD example Github

Test the APIs

Run our Node.js application with command:node server.js.

Using Postman, we're gonna test all the Apis above.

  • Create a new Tutorial usingPOST /tutorials Api

node-js-postgresql-crud-example-create

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 usingGET /tutorials Api

node-js-postgresql-crud-example-retrieve-all

  • Retrieve a single Tutorial by id usingGET /tutorials/:id Api

node-js-postgresql-crud-example-retrieve-one

  • Update a Tutorial usingPUT /tutorials/:id Api

node-js-postgresql-crud-example-update

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

node-js-postgresql-crud-example-search

  • Find all published Tutorials usingGET /tutorials/published Api

node-js-postgresql-crud-example-search-status

  • Delete a Tutorial usingDELETE /tutorials/:id Api

node-js-postgresql-crud-example-delete-one

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 usingDELETE /tutorials Api

node-js-postgresql-crud-example-delete-all

Now there are no rows intutorials table:

 id | title | description | published | createdAt | updatedAt----+-------+-------------+-----------+-----------+-----------

More Practice:

Node.js Express Pagination with PostgreSQL example

Node.js Express File Upload Rest API example

Node.js Express File Upload with Google Cloud Storage example

Security:

Node.js JWT Authentication & Authorization with PostgreSQL example

Associations:

Sequelize Associations: One-to-Many Relationship example

Sequelize Associations: Many-to-Many Relationship example

Fullstack:

Vue + Node.js + Express + PostgreSQL example

React + Node.js + Express + PostgreSQL example

Angular 8 + Node.js + Express + PostgreSQL example

Angular 10 + Node.js + Express + PostgreSQL example

Angular 11 + Node.js + Express + PostgreSQL example

Angular 12 + Node.js + Express + PostgreSQL example

Angular 13 + Node.js + Express + PostgreSQL example

Angular 14 + Node.js + Express + PostgreSQL example

Angular 15 + Node.js + Express + PostgreSQL example

Angular 16 + Node.js + Express + PostgreSQL example

Angular 17 + Node.js + Express + PostgreSQL example

Integration (run back-end & front-end on same server/port)

Integrate React with Node.js Restful Services

Integrate Angular with Node.js Restful Services

Integrate Vue with Node.js Restful Services

Project setup

npm install

Run

node server.js

About

Node.js Postgresql Crud example - Restful CRUD API with Express, Sequelize and PostgreSQL example

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

[8]ページ先頭

©2009-2025 Movatter.jp