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:
30
lib/User.js
30
lib/User.js
@@ -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, [
|
||||
|
||||
Reference in New Issue
Block a user