UNPKG

rethinkts

Version:

A model system for RethinkDB, written in and for TypeScript.

40 lines (39 loc) 1.42 kB
import { Term } from 'rethinkdbdash'; import { ColumnInfo } from './column'; import { Hooks } from './hooks'; import { RelationshipInfo } from './relationships'; export declare const modelInfoKey: symbol; export interface ModelCtor<T> { new (): T; } export interface IndexInfo { name: string; keys: string[] | ((r: Term<any>) => any); 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; }