You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
frontend/src/app/service/db/Codium.ts

88 lines
2.2 KiB

import {Model} from './Model';
export interface ICodium {
id?: number;
Language: string;
NodeId: string;
PageId: string;
code: string;
UUID: string;
needsServerUpdate?: boolean;
deleted?: boolean;
}
export class Codium extends Model<ICodium> implements ICodium {
id?: number;
Language: string;
NodeId: string;
PageId: string;
code: string;
UUID: string;
needsServerUpdate?: boolean;
deleted?: boolean;
public static getTableName() {
return 'codiums';
}
public static getSchema() {
return '++id, Language, NodeId, PageId, code, UUID, needsServerUpdate, deleted';
}
constructor(
Language: string,
NodeId: string,
PageId: string,
code: string,
UUID: string,
needsServerUpdate?: boolean,
deleted?: boolean,
id?: number
) {
super();
this.Language = Language;
this.NodeId = NodeId;
this.PageId = PageId;
this.code = code;
this.UUID = UUID;
if ( typeof needsServerUpdate !== 'undefined' ) {
this.needsServerUpdate = needsServerUpdate;
}
if ( typeof deleted !== 'undefined' ) {
this.deleted = deleted;
}
if ( id ) {
this.id = id;
}
}
public fillFromRecord(record: any) {
this.Language = record.Language;
this.NodeId = record.NodeId;
this.PageId = record.PageId;
this.code = record.code;
this.UUID = record.UUID;
}
public getSaveRecord(): any {
return {
...(this.id ? { id: this.id } : {}),
Language: this.Language,
NodeId: this.NodeId,
PageId: this.PageId,
code: this.code,
UUID: this.UUID,
...(typeof this.needsServerUpdate === 'undefined' ? {} : { needsServerUpdate: this.needsServerUpdate }),
...(typeof this.deleted === 'undefined' ? {} : { deleted: this.deleted }),
};
}
public getDatabase(): Dexie.Table<ICodium, number> {
return this.staticClass().dbService.table('codiums') as Dexie.Table<ICodium, number>;
}
}