mirror of
https://github.com/matt-fidd/stratos.git
synced 2026-01-01 18:39:32 +00:00
Added Subject.getAllSubjects method
This commit is contained in:
@@ -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;
|
||||||
|
|||||||
Reference in New Issue
Block a user