mirror of
https://github.com/matt-fidd/stratos.git
synced 2026-01-01 16:19:26 +00:00
Implemented Parent.getChildren
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user