diff --git a/lib/DatabaseModel.ts b/lib/DatabaseModel.ts index 06ba7ab..344fb9b 100644 --- a/lib/DatabaseModel.ts +++ b/lib/DatabaseModel.ts @@ -6,7 +6,15 @@ */ export abstract class DatabaseModel { - protected id?: number; + protected data: Record = {}; + + public get id (): number { + return this.data.id; + } + + public set id (val: number) { + this.data.id = val; + } public static async get ( id: number, @@ -18,14 +26,8 @@ export abstract class DatabaseModel { return dbm; } - public get object (): Record { - const obj = { id: this.id }; - return obj; - } - - public set object (obj: Record) { - this.id = obj.id as number | undefined; - } + 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;