export interface StorageCursor { limit(num: number): StorageCursor sort(params: {}): StorageCursor skip(offset: number): StorageCursor toArray(): Promise } export class ErrStorage extends Error {} export class ErrNoSession extends ErrStorage {} export abstract class Storage { protected _dsn: string constructor(dsn: string) { this._dsn = dsn } abstract find(name: string, query: Object): Promise abstract save(name: string, uniqKey: string, data: Object): Promise abstract createSession(): StorageSession abstract count(name: string, query?: object): Promise abstract remove(collectionName: string, uniqKeyName: string, uniqKey: string): Promise } export abstract class StorageSession { abstract start(options?: {}): Promise abstract commit(fn: () => any, options?: {}): Promise }