From d5bc5a9619bf86c21d3714767f972c6654a8098c Mon Sep 17 00:00:00 2001 From: matt Date: Fri, 25 Feb 2022 19:52:45 +0000 Subject: [PATCH] Add ability to extract Subject from Class --- lib/Class.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/lib/Class.js b/lib/Class.js index 559d329..8a9f44d 100644 --- a/lib/Class.js +++ b/lib/Class.js @@ -15,6 +15,12 @@ class Class { */ subjectId; + /** + * The subject the class is for + * @type {Subject} + */ + subject; + /** * The name of the class * @type {string} @@ -48,11 +54,16 @@ class Class { for (const [ k, v ] of Object.entries(record[0])) this[k] = v; + this.subject = await this.getSubject(); + return this; })(); } - get subject() { + async getSubject() { + return new (require('./Subject'))(this.subjectId); + } + }