-
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.
- Loading branch information
1 parent
538b87b
commit 1c3863d
Showing
1 changed file
with
20 additions
and
0 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,20 @@ | ||
const connect = require('../../database/db_connection.js'); | ||
|
||
const doesCustomerExistInDB = (userCredentials, callback) => { | ||
// query the database | ||
const databaseQuery = 'SELECT * FROM users WHERE stripe_id IS NOT NULL AND github_username = $1'; | ||
const databaseParams = [userCredentials.username]; | ||
connect.query(databaseQuery, databaseParams, (err, result) => { | ||
if (err) { | ||
callback(err); | ||
} else if (result.rows.length === 0) { | ||
callback(null, false); | ||
} else { | ||
callback(null, result.rows[0]); | ||
} | ||
}); | ||
// if user has stripe id then return it | ||
// otherwise return false | ||
}; | ||
|
||
module.exports = doesCustomerExistInDB; |