Skip to content

Simple CRUD server on Node.js with PostgreSQL databease

Notifications You must be signed in to change notification settings

cheatsnake/crud-postgresql

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PostgreSQL CRUD app

Simple CRUD app for PosrgreSQL on Node.js.
Created using pure pg module

Usage

  1. Create a new database and configurate .env file
DB_USER=user
DB_PASSWORD=password
DB_HOST=localhost
DB_PORT=5432
DB_NAME=DatabaseName
  1. Create tables using SQL scripts
CREATE TABLE person(
    id SERIAL PRIMARY KEY,
    name VARCHAR(64)
);
CREATE TABLE note(
    id SERIAL PRIMARY KEY,
    title VARCHAR(128),
    body VARCHAR(1024),
    person_id INTEGER,
    FOREIGN KEY (person_id) REFERENCES person (id)
);
  1. Install packages, build app and launch server
npm install
npm run build
npm start

By default servers is running on http://localhost:3000/