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

Close database connection when finished with it

This commit is contained in:
2022-02-25 19:52:46 +00:00
parent 0ac1b1bb73
commit f299ecd727
6 changed files with 14 additions and 0 deletions

View File

@@ -81,6 +81,8 @@ class Class {
classId classId
]); ]);
conn.close();
this.teacherIds = ids.map(record => record.id); this.teacherIds = ids.map(record => record.id);
const [ teachers, subject ] = await Promise.all([ const [ teachers, subject ] = await Promise.all([

View File

@@ -32,6 +32,8 @@ class PasswordReset {
token token
]); ]);
conn.close();
if (!record.length) if (!record.length)
throw new Error('No password reset found'); throw new Error('No password reset found');
@@ -69,6 +71,8 @@ class PasswordReset {
await conn.runQuery(sql, [ u.id ]); await conn.runQuery(sql, [ u.id ]);
conn.close();
const [ nonce, token ] = await PasswordReset.hashToken(u); const [ nonce, token ] = await PasswordReset.hashToken(u);
const d = new Date(); const d = new Date();

View File

@@ -35,6 +35,8 @@ class Subject {
subjectId, subjectId,
]); ]);
conn.close();
if (!record.length) if (!record.length)
throw new Error('No subject found'); throw new Error('No subject found');

View File

@@ -83,6 +83,8 @@ class Test {
testId, testId,
]); ]);
conn.close();
if (!record.length) if (!record.length)
throw new Error('No test found'); throw new Error('No test found');

View File

@@ -59,6 +59,8 @@ class TestTemplate {
testTemplateId, testTemplateId,
]); ]);
conn.close();
if (!record.length) if (!record.length)
throw new Error('No test template found'); throw new Error('No test template found');

View File

@@ -50,6 +50,8 @@ class User {
const res = const res =
await conn.runQuery(sql, [ userId ]); await conn.runQuery(sql, [ userId ]);
conn.close();
if (!res.length) if (!res.length)
continue; continue;