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

Implemented Parent.getChildren

This commit is contained in:
2022-04-22 04:45:18 +00:00
parent 61e149df4c
commit 23c6b1024b

View File

@@ -8,8 +8,26 @@ class Parent extends User {
super(conn, id, 'parent');
}
get children() {
async getChildren(fetchObjects = true) {
const sql = `
select
studentId
from
studentParentLink
where
parentId = ?;
`;
const children = await this._conn.runQuery(sql, [ this.id ]);
const childrenIds = children.map(c => c.studentId);
if (!fetchObjects)
return childrenIds;
return await Promise.all(childrenIds.map(id => {
return new User(this._conn, id, 'student');
}));
}
static async createParent(conn, fname, oname, lname, email, password) {