export interface Database extends Record { } export type ShallowDatabase = Record; export type NestedDatabaseId = number | string; export type NestedDatabase = Record; export type StorageIndex = number | string; export interface Storage { delete: (key: StorageIndex | StorageIndex[]) => void; read: (key?: StorageIndex | StorageIndex[]) => any; write: (key: StorageIndex | StorageIndex[], value: unknown) => void; } export interface ShallowOrm { get: () => Item; update: (data: Item) => void; } export interface NestedOrm> { count: () => number; create: (item: Omit) => Item; createMany: (items: Omit[]) => void; delete: (id: StorageIndex) => void; deleteMany: (ids: StorageIndex[]) => void; exists: (filters: Partial) => boolean; findById: (id: StorageIndex) => Item | undefined; findFirst: (filters?: Partial) => Item | undefined; findMany: (filters?: Partial) => Item[]; update: (id: StorageIndex, item: Partial>) => void; updateMany: (ids: StorageIndex[], item: Partial>) => number; } export type Orm> = { [Key in keyof Database]: Database[Key] extends Array ? Item extends { id: StorageIndex; } ? NestedOrm : ShallowOrm : ShallowOrm; };