This example uses pg to connect to a DigitalOcean PostgreSQL database, with support for JSONB (see the favorites
column in the dataset).
- Import the dataset if necessary
- Pass your database credentials in environment variables. To look up your DigitalOcean Database connection details, see the examples README. You have two options:
- Pass in the whole connection string in the
DATABASE_URL
environment variable. Note that you will need to set?ssl=true
instead of?sslmode=require
- Pass in each component separately in their own environment variables like so:
DB_HOST
—Server hostnameDB_PORT
—Server portDB_USER
—UsernameDB_PASSWORD
—PasswordDB_DATABASE
—DatabaseDB_SSL
—Use SSL? true/false
- The
DATABASE_URL
variable will be preferred over any others.
- Pass in the whole connection string in the
- Start the server:
node index.js
- View the app at http://localhost:3000