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

Added Subject.getAllSubjects method

This commit is contained in:
2022-03-07 14:45:33 +00:00
parent 27a4ecd7c1
commit 9dd5c1dd32

View File

@@ -46,6 +46,29 @@ class Subject {
return this; return this;
})(); })();
} }
static async getAllSubjects() {
const sql = `
select
subjectId as id
from
subject;
`;
const conn = await new DatabaseConnectionPool();
const records = await conn.runQuery(sql);
conn.close();
const objectPromises = [];
records.forEach(record => {
objectPromises.push(new Subject(record.id));
});
const objects = await Promise.all(objectPromises);
return objects;
}
} }
module.exports = Subject; module.exports = Subject;