Skip to content
postgres database with nodejs
JavaScript PLpgSQL
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.

Author: @shiryz

Maintainer: TBC

Getting Started

Clone this repo: git clone

Learning Outcomes

Building a database

  • Creating a build script in an .sql file
  • Using the DROP and IF EXISTS commands, for use on a test database
  • What cascade is for and when to use it
  • Execute a transaction using BEGIN & COMMIT

Connecting to a database

  • Connecting to a PostgreSQL server from a node server, including the setup of environment variables (heroku)

Running queries in Node

  • Understanding what a connection pool is and how to initialise and configure one using pg
  • Using pool.query with callbacks, to execute single queries to the database
  • Using parameterised queries (to prevent SQL injection)
  • Serving the query results to the front end

Postgres Connection Walkthrough

This exercise is designed to get you familiar with connecting to a database, querying it and viewing that information. We'll be using the npm module pg to connect our node server to a locally-hosted Postgres database.

Inspired by Matthew Glover and his awesome pg-app

You can’t perform that action at this time.