Fix bug in accounts.js database file
parent
73da74a870
commit
6c84b0433c
|
@ -79,7 +79,7 @@ async function generateHash(password) {
|
||||||
async function create(email, password, isAdmin, name) {
|
async function create(email, password, isAdmin, name) {
|
||||||
const hash = await generateHash(password);
|
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)`;
|
VALUES($1, $2, $3, $4)`;
|
||||||
await database.executeQuery(query, [email, hash, isAdmin, name]);
|
await database.executeQuery(query, [email, hash, isAdmin, name]);
|
||||||
}
|
}
|
||||||
|
@ -92,14 +92,14 @@ async function edit(id, email, password, isAdmin, name) {
|
||||||
SET email = $2,
|
SET email = $2,
|
||||||
password = $3,
|
password = $3,
|
||||||
admin = $4,
|
admin = $4,
|
||||||
name = $5
|
full_name = $5
|
||||||
WHERE user_id = $1;`;
|
WHERE user_id = $1;`;
|
||||||
await database.executeQuery(query, [id, email, hash, isAdmin, name]);
|
await database.executeQuery(query, [id, email, hash, isAdmin, name]);
|
||||||
} else {
|
} else {
|
||||||
const query = `UPDATE accounts.users
|
const query = `UPDATE accounts.users
|
||||||
SET email = $2,
|
SET email = $2,
|
||||||
admin = $3,
|
admin = $3,
|
||||||
name = $4
|
full_name = $4
|
||||||
WHERE user_id = $1;`;
|
WHERE user_id = $1;`;
|
||||||
await database.executeQuery(query, [id, email, isAdmin, name]);
|
await database.executeQuery(query, [id, email, isAdmin, name]);
|
||||||
}
|
}
|
||||||
|
@ -109,15 +109,15 @@ async function edit(id, email, password, isAdmin, name) {
|
||||||
async function remove(id) {
|
async function remove(id) {
|
||||||
const query = `DELETE FROM accounts.users
|
const query = `DELETE FROM accounts.users
|
||||||
WHERE user_id = $1
|
WHERE user_id = $1
|
||||||
RETURNING email, admin, name;`;
|
RETURNING email, admin, full_name;`;
|
||||||
const row = (await database.executeQuery(query, [id]))[0];
|
const row = (await database.executeQuery(query, [id]))[0];
|
||||||
return new User(id, row[0], row[1], row[2]);
|
return new User(id, row[0], row[1], row[2]);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function retrieveAll() {
|
async function retrieveAll() {
|
||||||
const query = `SELECT user_id, email, admin, name
|
const query = `SELECT user_id, email, admin, full_name
|
||||||
FROM accounts.users
|
FROM accounts.users
|
||||||
ORDER BY name;`;
|
ORDER BY full_name;`;
|
||||||
const table = await database.executeQuery(query);
|
const table = await database.executeQuery(query);
|
||||||
|
|
||||||
const accountsList = [];
|
const accountsList = [];
|
||||||
|
@ -128,7 +128,7 @@ async function retrieveAll() {
|
||||||
}
|
}
|
||||||
|
|
||||||
async function getFromID(id) {
|
async function getFromID(id) {
|
||||||
const query = `SELECT user_id, email, admin, name
|
const query = `SELECT user_id, email, admin, full_name
|
||||||
FROM accounts.users
|
FROM accounts.users
|
||||||
WHERE user_id = $1;`;
|
WHERE user_id = $1;`;
|
||||||
const row = (await database.executeQuery(query, [id]))[0];
|
const row = (await database.executeQuery(query, [id]))[0];
|
||||||
|
|
Reference in New Issue