-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
connects dbConnection and db_build.js to build the database
Relates #1
- Loading branch information
1 parent
83c634c
commit 0c9ddd6
Showing
5 changed files
with
46 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
EMO_DB_URL = postgres://emoadmin:adminemo@localhost:5432/emotions |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
const pgp = require('pg-promise')(); | ||
// require('env2')('./config.env'); | ||
|
||
const herokuDB = { | ||
host: process.env.HEROKU_HOST, | ||
user: process.env.HEROKU_USER, | ||
password: process.env.HEROKU_PW, | ||
database: process.env.HEROKU_DB, | ||
ssl: true, | ||
}; | ||
|
||
const localDB = { | ||
host: 'localhost', | ||
port: 5432, | ||
database: 'emotions', | ||
user: 'emoadmin', | ||
password: 'adminemo' | ||
}; | ||
|
||
// const testDB = { | ||
// host: 'localhost', | ||
// port: 5432, | ||
// database: 'emotions', | ||
// user: 'emoadmin', | ||
// password: 'adminemo' | ||
// }; | ||
|
||
// let DB_URL = process.env.EMO_DB_URL; | ||
|
||
// if (!DB_URL) { | ||
// throw new Error('Environmental variable DB_URL needs to be set'); | ||
// } | ||
|
||
const connection = process.env.NODE_ENV === 'production' ? herokuDB : localDB; | ||
|
||
const db = pgp(connection); | ||
module.exports = db; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,7 +16,7 @@ CREATE TABLE scores ( | |
score FLOAT(4) NOT NULL, -- should give about 7 decimal places (4-bytes worth) | ||
emotion VARCHAR(20), | ||
img VARCHAR(100) | ||
) | ||
); | ||
|
||
INSERT INTO users (name,email,pw_hash) VALUES | ||
('Nicolas Cage', '[email protected]', 'placeholder'), | ||
|