export type DbbyValue = | undefined | boolean | number | string | bigint export type DbbyRow = { [P in keyof T]: DbbyValue } export interface DbbyConditions { set?: Partial<{[P in keyof Row]: true}> equal?: Partial less?: Partial lessy?: Partial greater?: Partial greatery?: Partial listed?: Partial search?: Partial<{[P in keyof Row]: string | RegExp}> notSet?: Partial<{[P in keyof Row]: true}> notEqual?: Partial notLess?: Partial notLessy?: Partial notGreater?: Partial notGreatery?: Partial notListed?: Partial notSearch?: Partial<{[P in keyof Row]: string | RegExp}> } export interface DbbyNonConditional { conditions: false | null } export interface DbbySingleConditional { conditions: DbbyConditions } export interface DbbyMultiConditional { multi: "and" | "or" conditions: DbbyConditions[] } export type DbbyUpsert = DbbyConditional & {upsert: Row} export type DbbyWrite = DbbyConditional & {write: Partial} export type DbbyWhole = DbbyConditional & {whole: Row} export type DbbyUpdate = DbbyWrite | DbbyWhole | DbbyUpsert export type DbbyUpdateAmbiguated = DbbyWrite & DbbyWhole & DbbyUpsert export type DbbyConditional = | DbbySingleConditional | DbbyMultiConditional | DbbyNonConditional export type DbbyOrder = Partial<{ [P in keyof Row]: "ascend" | "descend" | undefined }> export type DbbyPaginated = DbbyConditional & { limit?: number offset?: number order?: Partial<{[P in keyof Row]: "ascend" | "descend" | undefined}> } export type DbbyAssertion = DbbyConditional & { make: () => Promise } export interface DbbyTable { create(row: Row, ...args: Row[]): Promise read(options: DbbyPaginated): Promise one(options: DbbyConditional): Promise assert(options: DbbyAssertion): Promise update(options: DbbyUpdate): Promise delete(options: DbbyConditional): Promise count(options: DbbyConditional): Promise } export interface DbbyStorage { save(table: Row[]): void load(): Row[] }