/* * Copyright (C) Sapphirecode - All Rights Reserved * This file is part of Modelling which is released under MIT. * See file 'LICENSE' for full license details. * Created by Timo Hocker , May 2020 */ export abstract class DatabaseModel { protected id?: number; public static async get ( id: number, constructor: new () => T ): Promise { const dbm = (new constructor); dbm.id = id; await dbm.read (); 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 read(): Promise; public abstract write(): Promise; }