Setting Up
1. Create database
- Options:
- Running the command
createdb restaurant_directory
in the terminal.- PostgreSQL documentation: createdb
- Using
psql
command line interface, runCREATE DATABASE restaurant_directory;
then check that it was created successfully by running,SELECT datname FROM pg_catalog.pg_database WHERE lower(datname) = lower('restaurant_directory');
, OR by looking at the databases in a GUI like Postico.- To exit
psql
, type\q
and press enter. - PostgreSQL documentation: CREATE DATABASE
- To exit
- Using a GUI like Postico. Interfaces vary, but it should be user-friendly enough as to click a
+Database
button and type in the database name,restaurant_directory
.
- Running the command
2. Run seed
npm run seed
in your terminal.- See the
package.json
file to see what this command runs:"seed": "psql -d restaurant_directory -a -f ./restaurants.sql"
-d [dbname]
: short for--dbname=dbname
, the database name to connect to-a
: short for--echo-all
, prints all nonempty input lines to std output-f [filename]
: short for--file=filename
, reads commands from the filename
- See the
3. Code away
- Go to the
app.js
file and play around with queries usingpg
(node-postgres).