UNPKG

memory-orm

Version:
82 lines (81 loc) 1.87 kB
import { Datum } from './datum' import { DATA, Memory, Reduce, Cache, OrderCmd, SetContext, Emitter, LeafCmd, NameBase, CLASS, DEFAULT_RULE_TYPE, } from './type' import { Model } from './model' import { Map } from './map' import { Struct } from './struct' import { List } from './list' import { Query } from './query' declare type Emitters = { order: Emitter<OrderCmd> reduce: Emitter<LeafCmd> & { default: Emitter<LeafCmd> default_origin: Emitter<LeafCmd> } } declare type ReduceContext<A extends DEFAULT_RULE_TYPE> = { map: typeof Map query: Query<A> memory: Memory cache: Cache['$format'] paths: { _reduce: Reduce } } export declare class Finder<A extends DEFAULT_RULE_TYPE> { $name: NameBase all: Query<A> model: typeof Model | typeof Struct list: CLASS<List<A>> map: typeof Map constructor() join({ $name, model, all, map, list, }: { $name: NameBase all: Query<A> map: typeof Map list: CLASS<List<A>> model: typeof Model | typeof Struct }): void calculate(query: Query<A>, memory: Memory): void reduce({ map, cache, paths, query, memory }: ReduceContext<A>, ids: string[]): void finish({ map, paths, query }: ReduceContext<A>): void data_set(type: string, from: DATA<A[0]>, parent: Object | undefined): any data_emitter( { base, journal }: SetContext<A>, { item, $group, }: { item: any $group: any } ): Emitters data_init( { model, parent, deploys }: SetContext<A>, { item }: Datum, { reduce, order }: Emitters ): void data_entry({ model }: SetContext<A>, { item }: Datum, { reduce, order }: Emitters): void reset(ctx: SetContext<A>): boolean merge(ctx: SetContext<A>): boolean remove(ctx: SetContext<A>): boolean update(ctx: SetContext<A>, parent: Object): boolean } export {}