fix: обновил ts
This commit is contained in:
1 parent
aa38fae8cc
commit
def5b75101
5 files changed
+71
-51
No files matched your search
@@ -0,0 +1,42 @@
|
||||
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<ItemData> {
|
||||
_getRepo(storage: Storage): ItemsRepo {
|
||||
return new ItemsRepo(storage)
|
||||
}
|
||||
|
||||
_getVO(): ItemData {
|
||||
return new ItemData()
|
||||
}
|
||||
}
|
||||
export class ItemsRepo extends RepoSQLite<ItemEntity> {
|
||||
Entity(): ItemEntity {
|
||||
return new ItemEntity()
|
||||
}
|
||||
|
||||
Name(): string {
|
||||
return 'items'
|
||||
}
|
||||
|
||||
async Create(): Promise<void> {
|
||||
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
|
||||
)
|
||||
`)
|
||||
}
|
||||
}
|
||||
@@ -1,47 +1,6 @@
|
||||
import { Data } from '../../app/data'
|
||||
import { Entity } from '../../app/entity'
|
||||
import { Storage } from '../../app/storage'
|
||||
import { Repo } from '../../app/repo'
|
||||
import { RepoSQLite } from '../../app/repo/sqlite'
|
||||
import { StorageSQLite } from '../../app/storage/sqlite'
|
||||
import { assert } from 'chai'
|
||||
|
||||
class ItemData extends Data {
|
||||
uniqKey(): string {
|
||||
return 'uid'
|
||||
}
|
||||
|
||||
uid: string
|
||||
title: string
|
||||
}
|
||||
class ItemEntity extends Entity<ItemData> {
|
||||
_getRepo(storage: Storage): Repo<Entity<ItemData>> {
|
||||
return undefined
|
||||
}
|
||||
|
||||
_getVO(): ItemData {
|
||||
return new ItemData()
|
||||
}
|
||||
}
|
||||
class ItemsRepo extends RepoSQLite<ItemEntity> {
|
||||
Entity(): ItemEntity {
|
||||
return new ItemEntity()
|
||||
}
|
||||
|
||||
Name(): string {
|
||||
return 'items'
|
||||
}
|
||||
|
||||
async Create(): Promise<void> {
|
||||
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
|
||||
)
|
||||
`)
|
||||
}
|
||||
}
|
||||
import { ItemData, ItemEntity, ItemsRepo } from './helper'
|
||||
|
||||
describe('ItemsRepoSQLite', () => {
|
||||
const dsn = __dirname + `/sqlite.test.db`
|
||||
|
||||
Reference in new issue
Block a user