modelling/lib/DatabaseModel.ts
2020-05-02 21:14:54 +02:00

38 lines
884 B
TypeScript

/*
* 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 <timo@scode.ovh>, May 2020
*/
export abstract class DatabaseModel {
protected data: Record<string, string|number|boolean> = {};
public get id (): number {
return this.data.id as number;
}
public set id (val: number) {
this.data.id = val;
}
public get object (): Record<string, string|number|boolean> {
return this.data;
}
public constructor (id: number) {
this.id = id;
}
public get (key: string): string|number|boolean {
return this.data[key];
}
public set (key: string, value: string|number|boolean): void {
this.data[key] = value;
}
public abstract async read(): Promise<void>;
public abstract async write(): Promise<void>;
}