UNPKG

pims

Version:

An ORM for document-oriented database systems, written in and for TypeScript.

32 lines (31 loc) 1.53 kB
import { Adapter, QueryOptions, GetOptions, JoinOptions } from './index'; import { ModelCtor } from '../model'; export interface AdapterOptions { models: ModelCtor<any>[]; } export declare abstract class AdapterBase implements Adapter { private models; constructor(opts: AdapterOptions); /** * Ensures all tables exist, and waits for them to be ready. */ ensure(): Promise<void>; /** * Save the model to the Database. * * If replace is set to true, the entire model will be **replaced**. Otherwise * default action would be to update the document. */ save<M>(model: M, replace?: boolean): Promise<M>; delete<M>(model: M): Promise<void>; join<M>(model: M, relationshipKey: string, opts?: JoinOptions): Promise<M>; private getModelByName<T>(name); abstract all<T>(ctor: ModelCtor<T>, opts?: QueryOptions): Promise<T[]>; abstract find<T>(ctor: ModelCtor<T>, filter: Partial<T>, opts?: QueryOptions): Promise<T[]>; abstract findOne<T>(ctor: ModelCtor<T>, filter: Partial<T>, opts?: QueryOptions): Promise<T>; abstract get<T>(ctor: ModelCtor<T>, value: any, opts?: GetOptions): Promise<T[]>; abstract getOne<T>(ctor: ModelCtor<T>, value: any, opts?: GetOptions): Promise<T>; protected abstract ensureTable(ctor: ModelCtor<any>): Promise<void>; protected abstract updateStore(model: any, payload: any, replace: boolean): Promise<void>; protected abstract deleteFromStore(model: any): Promise<void>; }