import { IdCreatedUpdated, IIdCreatedUpdated } from '../models/id-created-updated.mjs' import { IIdName } from '../models/id-name.mjs' import { IIdVal } from '../models/id-val.mjs' import { NameValType } from '../models/name-val.mjs' import { isObject } from '../services/general.mjs' export interface IConfig extends IIdVal, IIdName, IIdCreatedUpdated { userid: Tid } export default class Config extends IdCreatedUpdated implements IConfig { userid!: Tid name = '' val!: Tval constructor( id: Tid | IConfig, userid: Tid, name = '', val: Tval, updatedby = 'Config', updated = new Date(), createdby = 'Config', created = new Date() ) { super(id, createdby, created, updatedby, updated) if (isObject(id)) { this.copyFromDatabase(id as IConfig) } else { // constructor items this.userid = userid this.name = name this.val = val } } copyFromDatabase(dbtp: IConfig) { super.copyFromDatabase(dbtp) this.userid = dbtp.userid this.name = dbtp.name this.val = dbtp.val } api(): NameValType { return { name: this.name, val: this.val, } } } export type ConfigType = { id: Tid userid: Tid name: string val: Tval updatedby: string updated: Date createdby: string created: Date }