-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #47 from fac-13/getqueries
write get queries
- Loading branch information
Showing
5 changed files
with
50 additions
and
19 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 |
---|---|---|
|
@@ -39,4 +39,4 @@ | |
"mocha": "^5.1.1", | ||
"pg-promise": "^8.4.3" | ||
} | ||
} | ||
} |
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
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 |
---|---|---|
@@ -1,28 +1,27 @@ | ||
const dbConnect = require('../database/db_connect.js'); | ||
|
||
// get username and password from users table | ||
const getUserData = username => dbConnect.query('SELECT password FROM users WHERE username=$1', [username]) | ||
.then(res => res[0]); | ||
|
||
// get a symptom from symptoms table | ||
const getSymptoms = userId => dbConnect.query('SELECT * FROM symptoms WHERE user_id=$1', [userId]); | ||
// get scale comments for symptom scale | ||
|
||
// get a factor from factors table | ||
const getFactors = userId => dbConnect.query('SELECT * FROM factors WHERE user_id=$1', [userId]); | ||
|
||
// get username and password from users table | ||
// get all user symptoms from symptoms table | ||
const getSymptoms = username => dbConnect.query('select symptom from symptoms where user_id = (select id from users where username=$1)', [username]); | ||
// get all user factors from factor table | ||
|
||
// get a symptom from symptoms table | ||
const getFactors = username => dbConnect.query('select factor from factors where user_id = (select id from users where username=$1)', [username]); | ||
|
||
// get scale comments for symptom scale | ||
|
||
// get a factor from factors table | ||
const getSymptomScale = (symptom, username) => dbConnect.query('select * from symptom_scale where symptom_id = (select id from symptoms where symptom=$1) and user_id = (select id from users where username=$2);)', [symptom, username]); | ||
|
||
// get scale comment for factor scale | ||
const getFactorScale = (factor, username) => dbConnect.query('select * from factor_scale where factor_id = (select id from factors where factor=$1) and user_id = (select id from users where username=$2);)', [factor, username]); | ||
|
||
// get specific symptom ratings | ||
|
||
// get specific factor ratings | ||
|
||
module.exports = { getUserData, getSymptoms, getFactors }; | ||
// get specific symptom data | ||
const getSymptomRatings = username => dbConnect.query('select symptom_data.rating, symptom_data.date_entered, symptoms.symptom from symptom_data left join symptoms on symptoms.id = symptom_data.symptom_id where symptom_data.user_id = (select id from users where username=$1)', [username]); | ||
// get specific factor data | ||
const getFactorRatings = username => dbConnect.query('select factor_data.rating, factor_data.date_entered, factors.factor from factor_data left join factors on factors.id = factor_data.factor_id where factor_data.user_id = (select id from users where username=$1)', [username]); | ||
|
||
module.exports = { | ||
getUserData, getSymptoms, getFactors, getSymptomScale, getFactorScale, getSymptomRatings, getFactorRatings, | ||
}; |
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