1
0
mirror of https://github.com/matt-fidd/stratos.git synced 2026-01-01 17:59:25 +00:00

Consistent SQL query formatting

This commit is contained in:
2022-02-25 14:44:35 +00:00
parent 2fac6e7aba
commit 57af81cc98
4 changed files with 87 additions and 23 deletions

View File

@@ -38,7 +38,8 @@ class User {
lastName,
password,
${type}Id as id
from ${type}
from
${type}
where
${type}Id = ?;
`;
@@ -90,9 +91,12 @@ class User {
const conn = await new DatabaseConnectionPool();
const sql = `
update ${this.type}
set password = ?
where ${this.type}Id = ?;
update
${this.type}
set
password = ?
where
${this.type}Id = ?;
`;
await conn.runQuery(sql, [ newPassword, this.id ]);
@@ -134,10 +138,10 @@ class User {
switch (range) {
case 'before':
sql += `and t.testDate < CURDATE()`;
sql += `and t.testDate < curdate()`;
break;
case 'after':
sql += `and t.testDate > CURDATE()`;
sql += `and t.testDate > curdate()`;
break;
}
@@ -164,14 +168,15 @@ class User {
const hashedPassword = await User.hashPassword(password);
const sql = `
insert into ${type} (
insert into ${type}(
${type}Id,
email,
firstName,
otherNames,
lastName,
password)
VALUES (?, ?, ?, ?, ?, ?);
values
(?, ?, ?, ?, ?, ?);
`;
await conn.runQuery(sql, [
@@ -202,9 +207,12 @@ class User {
for (const type of types) {
const sql = `
select ${type}id as id
from ${type}
where email = ?;
select
${type}id as id
from
${type}
where
email = ?;
`;
const id = (await conn.runQuery(sql, [