Skip to content

It contains different utilities and operations of PostgreSQL with NodeJS

Notifications You must be signed in to change notification settings

kingshuknandy2016/node-typescript-postgresql

Repository files navigation

Nodejs Project with PostgreSQL Setup

NodeJS TypeScript PostgreSQL

This Node.js PostgreSQL project exemplifies a streamlined database setup using db-migration for efficient table creation and data seeding. The integration of the pg module enhances data querying capabilities, providing a seamless interface between the Node.js application and PostgreSQL database. Ideal for developers seeking a concise and effective solution for database management in Node.js projects, this GitHub repository offers a combination of structured migration workflows and powerful data querying using the 'pg' module.The migration scripts, conveniently managed through a dedicated tool, facilitate version control and ease of deployment.

Table on Contents

Quick Start

  • Install the dependencies
  npm install
  • Start the app in dev mode
   npm run start:dev
  • Builds the app at build, cleaning the folder first.
   npm run build,
  • Start the app in production
npm run start

Database Setup using Docker

Get your application DB up. Ensure that you have docker installed. We are using Postgres Docker container as the Database

  • Pull the PostgreSQL Docker Image

    docker pull postgres
  • Run the PostgreSQL Container

    docker run --name postgres-db -p 5432:5432 -e POSTGRES_PASSWORD=password -d postgres
  • Connect to the PostgreSQL Container

    docker exec -it postgres-db psql -U postgres

Table Creation and Data-seeding

Create the table and seed random data into it

  npm run migrate:initialize

Delete the table

  npm run migrate:all-delete

If you want to create new migration, execute the following command

node node_modules/db-migrate/bin/db-migrate create migration-name --sql-file

And then update the up sql file with the database statements

Different Database Design

Employee Management Database Design

Step A : Identify the Entities and their relationship

  • Employee has name , email ,contact number, designation, role
  • Every employee is associated with a Business Unit

Step B : Create the ERD Employee Management ERD

Step C: Export the ERD as plsql statements

About

It contains different utilities and operations of PostgreSQL with NodeJS

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published