diff --git a/lib/ControlModel.ts b/lib/ControlModel.ts index 165bf6b..9ced8b9 100644 --- a/lib/ControlModel.ts +++ b/lib/ControlModel.ts @@ -10,6 +10,7 @@ import { Persistent } from './Persistent'; export abstract class ControlModel extends Persistent { public constructor (obj?: Record) { super (); + this.define_properties (); for (const prop of Object.keys (this.properties)) { if ([ 'string', @@ -43,4 +44,5 @@ export abstract class ControlModel extends Persistent { } public abstract verify(): void; + protected abstract define_properties(): void; } diff --git a/lib/DatabaseModel.ts b/lib/DatabaseModel.ts index 97468a8..dc7b0cb 100644 --- a/lib/DatabaseModel.ts +++ b/lib/DatabaseModel.ts @@ -15,6 +15,7 @@ export abstract class DatabaseModel extends Persistent { public constructor (id?: number) { super (); this.properties.id = 'number'; + this.define_properties (); for (const prop of Object.keys (this.properties)) { if ([ 'string', @@ -45,4 +46,5 @@ export abstract class DatabaseModel extends Persistent { public abstract async read(): Promise; public abstract async write(): Promise; public abstract async delete(): Promise; + protected abstract define_properties(): void; } diff --git a/lib/Persistent.ts b/lib/Persistent.ts index 851d452..697d121 100644 --- a/lib/Persistent.ts +++ b/lib/Persistent.ts @@ -2,13 +2,7 @@ import { Assignable, Serializable } from './interfaces'; export abstract class Persistent implements Assignable, Serializable { private _data: Record = {}; - protected readonly properties: Record; - - public constructor () { - this.properties = this.define_properties (); - } - - protected abstract define_properties(): Record; + protected readonly properties: Record = {}; public assign (a: Assignable): void { this.assign_object (a.to_object ());