Inspired by Shireen Zoaby original workshop and converted it to use express and promises and the WHATWG URL API.
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 promises, to execute single queries to the database
- Serving the query results to the front end
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 - documentation here - to connect our node server to a locally-hosted Postgres database.