Setup Database

Create database

Connect to postgres with psql

psql -U postgres

Run create database command

create database dev_demo_db;

Exit psql

\q

Enter connection string into .env file

# .env
DATABASE_URL=postgres://postgres:<password>@localhost:5432/dev_demo_db

Setup database driver

Install pg database driver

npm install pg

Create database module

Create db.js file

touch src/db/index.js

Code a shared connection pool

// db/index.js
import pg from 'pg';

const { Pool } = pg;
const pool = new Pool({
  connectionString: process.env.DATABASE_URL
});

export default pool;

Commit

git add .
git commit -m 'Adds db index file'

Next:
Setup Migrations