import { ISaveOptions } from './framework/ISaveOptions'; import { IFindOptions } from './framework/IFindOptions'; import { IEntityRef, ISchemaRef } from '@allgemein/schema-api'; import { IUpdateOptions } from './framework/IUpdateOptions'; import { IAggregateOptions } from './framework/IAggregateOptions'; import { IDeleteOptions } from './framework/IDeleteOptions'; import { CLS_DEF } from '../Constants'; import { IStorageRef } from './IStorageRef'; /** * Abstraction for an backend entity managing and querying interface. Condition should be passed in mango schema. */ export interface IEntityController { name(): string; forClass(cls: CLS_DEF): IEntityRef; /** * Return query for id search * * @param cls * @param entity */ entityIdQuery?(cls: IEntityRef, entity: any): any; findOne(fn: CLS_DEF, conditions?: any, options?: IFindOptions): Promise; find(fn: CLS_DEF, conditions?: any, options?: IFindOptions): Promise; save(object: T, options?: ISaveOptions): Promise; save(object: T[], options?: ISaveOptions): Promise; remove(object: T | T[], options?: IDeleteOptions): Promise; remove(cls: CLS_DEF, condition?: any, options?: IDeleteOptions): Promise; update(cls: CLS_DEF, condition: any, update: any, options?: IUpdateOptions): Promise; aggregate(baseClass: CLS_DEF, pipeline: any[], options?: IAggregateOptions): Promise; /** * Return schema reference of this controller if one exists */ getSchemaRef?(): ISchemaRef; /** * Return the storage reference of this controller */ getStorageRef?(): IStorageRef; /** * Pass a raw query without any abstraction directly to the backend system * * @param query * @param options */ rawQuery?(query: any, options?: any): any; }