From d504f892c088ea2714e4abe677b1d2330bae0e43 Mon Sep 17 00:00:00 2001 From: Timo Hocker Date: Sat, 2 May 2020 20:03:14 +0200 Subject: [PATCH] simplification --- lib/DatabaseModel.ts | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/lib/DatabaseModel.ts b/lib/DatabaseModel.ts index 344fb9b..a933f6c 100644 --- a/lib/DatabaseModel.ts +++ b/lib/DatabaseModel.ts @@ -16,19 +16,13 @@ export abstract class DatabaseModel { this.data.id = val; } - public static async get ( - id: number, - constructor: new () => T - ): Promise { - const dbm = (new constructor); - dbm.id = id; - await dbm.read (); - return dbm; + public constructor (id) { + this.id = id; } public abstract get(key: string): string|number|boolean; public abstract set(key: string, value: string|number|boolean); - public abstract read(): Promise; - public abstract write(): Promise; + public abstract async read(): Promise; + public abstract async write(): Promise; }