UNPKG

pims

Version:

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

39 lines (38 loc) 1.36 kB
import { ColumnInfo } from './column'; import { Hooks } from './hooks'; import { RelationshipInfo } from './relationships'; export declare const modelInfoKey: unique symbol; export interface ModelCtor<T> { new (): T; } export interface IndexInfo { name: string; keys: string[]; options?: { multi?: boolean; geo?: boolean; }; } export interface ModelInfo { database: string; table: string; columns: ColumnInfo[]; indexes: IndexInfo[]; primaryKey: string; tags: Map<string, Set<string>>; relationships: RelationshipInfo[]; } export declare function createModelInfo(target: ModelCtor<any>, ...objs: Partial<ModelInfo>[]): ModelInfo; /** * Model decorator */ export declare function Model(info: Partial<ModelInfo>): ClassDecorator; export declare namespace Model { function construct<M>(ctor: ModelCtor<M>, data: Partial<M>): M; function assign<M>(model: M, ...sources: Partial<M>[]): M; function pickAssign<M>(model: M, tagsOrKeys: string[] | string, ...sources: Partial<M>[]): M; function pick<M>(model: M, ...tagsOrKeys: string[]): Partial<M>; function without<M>(model: M, ...tagsOrKeys: string[]): Partial<M>; function getInfo(ctor: ModelCtor<any>): ModelInfo; function notify(model: any, hook: Hooks, ...args: any[]): any; }