diff options
author | RossTheRoss <mstrapp@protonmail.com> | 2021-05-16 21:38:59 -0500 |
---|---|---|
committer | RossTheRoss <mstrapp@protonmail.com> | 2021-05-16 21:38:59 -0500 |
commit | 9148fa6e2fad9d54e3451a4478e03f55f0a9fa3c (patch) | |
tree | 9e739b11361f5fd122b31cfce107947502b69809 /csci4131/hw6/strap012_hw6/dbio.js | |
parent | Add trash (diff) | |
download | homework-9148fa6e2fad9d54e3451a4478e03f55f0a9fa3c.tar homework-9148fa6e2fad9d54e3451a4478e03f55f0a9fa3c.tar.gz homework-9148fa6e2fad9d54e3451a4478e03f55f0a9fa3c.tar.bz2 homework-9148fa6e2fad9d54e3451a4478e03f55f0a9fa3c.tar.lz homework-9148fa6e2fad9d54e3451a4478e03f55f0a9fa3c.tar.xz homework-9148fa6e2fad9d54e3451a4478e03f55f0a9fa3c.tar.zst homework-9148fa6e2fad9d54e3451a4478e03f55f0a9fa3c.zip |
Rearrange files
Diffstat (limited to 'csci4131/hw6/strap012_hw6/dbio.js')
-rw-r--r-- | csci4131/hw6/strap012_hw6/dbio.js | 74 |
1 files changed, 0 insertions, 74 deletions
diff --git a/csci4131/hw6/strap012_hw6/dbio.js b/csci4131/hw6/strap012_hw6/dbio.js deleted file mode 100644 index 302334b..0000000 --- a/csci4131/hw6/strap012_hw6/dbio.js +++ /dev/null @@ -1,74 +0,0 @@ -var mysql = require("mysql"); -var bcrypt = require("bcrypt"); - -var connection = mysql.createConnection({ - host: "cse-mysql-classes-01.cse.umn.edu", - user: "C4131S21U83", - password: "6919", - database: "C4131S21U83", - port: 3306 -}); - -connection.connect(function(err) { - if (err) { - throw err; - }; - console.log("Connected to MYSQL database!"); -}); - -function passcheck(user,pass) { - return new Promise(function(resolve, reject) { - connection.query('SELECT * FROM tbl_accounts', function(err, rows, fields) { - let ret = []; - if (err) { - return reject(err); - } - for (var i = 0; i < rows.length; i++) { - if (rows[i].acc_login.localeCompare(user) === 0) { - if (bcrypt.compareSync(pass, rows[i].acc_password)) { - ret += rows[i]; - } - } - } - resolve(ret); - }); - }); -} - -function getContacts() { - return new Promise (function(resolve, reject) { - let conTab = [] - connection.query('SELECT * FROM tbl_contacts', function (err, rows, fields) { - if (err) { - return reject(err); - } - resolve(rows); - }); - }); -} - -function addContacts(contact) { - let newCon = { - name: contact.name, - category: contact.category, - location: contact.location, - contact_info: contact.contact, - email: contact.email, - website_url: contact.website_name, - } - return new Promise(function(resolve, reject) { - connection.query('INSERT tbl_contacts SET ?', newCon, function (err, result) { //Parameterized insert - if (err) throw err; - console.log("Values inserted"); - resolve(); - }); - }); - -} - - - - -exports.addContact = addContacts; -exports.query = passcheck; -exports.getContacts = getContacts; |