From 6c84b0433c2f798fb044106c758d365272a77e8e Mon Sep 17 00:00:00 2001 From: sudoer777 <78781902+sudoer777@users.noreply.github.com> Date: Thu, 2 Dec 2021 13:22:47 -0700 Subject: [PATCH] Fix bug in accounts.js database file --- database/accounts/accounts.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/database/accounts/accounts.js b/database/accounts/accounts.js index 8334d27..921a1cf 100644 --- a/database/accounts/accounts.js +++ b/database/accounts/accounts.js @@ -79,7 +79,7 @@ async function generateHash(password) { async function create(email, password, isAdmin, name) { const hash = await generateHash(password); - const query = `INSERT INTO accounts.users(email, password, admin, name) + const query = `INSERT INTO accounts.users(email, password, admin, full_name) VALUES($1, $2, $3, $4)`; await database.executeQuery(query, [email, hash, isAdmin, name]); } @@ -92,14 +92,14 @@ async function edit(id, email, password, isAdmin, name) { SET email = $2, password = $3, admin = $4, - name = $5 + full_name = $5 WHERE user_id = $1;`; await database.executeQuery(query, [id, email, hash, isAdmin, name]); } else { const query = `UPDATE accounts.users SET email = $2, admin = $3, - name = $4 + full_name = $4 WHERE user_id = $1;`; await database.executeQuery(query, [id, email, isAdmin, name]); } @@ -109,15 +109,15 @@ async function edit(id, email, password, isAdmin, name) { async function remove(id) { const query = `DELETE FROM accounts.users WHERE user_id = $1 - RETURNING email, admin, name;`; + RETURNING email, admin, full_name;`; const row = (await database.executeQuery(query, [id]))[0]; return new User(id, row[0], row[1], row[2]); } async function retrieveAll() { - const query = `SELECT user_id, email, admin, name + const query = `SELECT user_id, email, admin, full_name FROM accounts.users - ORDER BY name;`; + ORDER BY full_name;`; const table = await database.executeQuery(query); const accountsList = []; @@ -128,7 +128,7 @@ async function retrieveAll() { } async function getFromID(id) { - const query = `SELECT user_id, email, admin, name + const query = `SELECT user_id, email, admin, full_name FROM accounts.users WHERE user_id = $1;`; const row = (await database.executeQuery(query, [id]))[0];