Fix bug in accounts.js database file

main
sudoer777 2021-12-02 13:22:47 -07:00
parent 73da74a870
commit 6c84b0433c
1 changed files with 7 additions and 7 deletions

View File

@ -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];