import { Data } from '../../app/data' import { Entity } from '../../app/entity' import { RepoSQLite } from '../../app/repo/sqlite' import { StorageSQLite } from '../../app/storage/sqlite' import { Storage } from '../../app/storage' export class ItemData extends Data { uniqKey(): string { return 'uid' } uid: string title: string } export class ItemEntity extends Entity { _getRepo(storage: Storage): ItemsRepo { return new ItemsRepo(storage) } _getVO(): ItemData { return new ItemData() } } export class ItemsRepo extends RepoSQLite { Entity(): ItemEntity { return new ItemEntity() } Name(): string { return 'items' } async Create(): Promise { const st = this._storage as StorageSQLite await st?.db?.run(` create table if not exists ${this.Name()} ( uid varchar(255) not null unique, title text null ) `) } }