UNPKG

octonom

Version:

Object Document Mapper for any database

18 lines (17 loc) 618 B
import { IModelConstructor, Model } from './model'; export interface ICollectionOptions<T extends Model> { modelIdField?: keyof T; } export interface ICollectionInsertOptions { validate?: boolean; } export declare abstract class Collection<T extends Model> { readonly model: IModelConstructor<T>; protected options: ICollectionOptions<T>; readonly modelIdField: string; constructor(model: IModelConstructor<T>, options?: ICollectionOptions<T>); abstract findById(id: string): Promise<T>; findByIds(ids: string[]): Promise<T[]>; toDb(model: T): object; fromDb(doc: object): T; }