@goatlab/fluent
Version:
Readable query Interface & API generator for TS and Node
93 lines (92 loc) • 2.19 kB
TypeScript
import { ColumnType } from 'typeorm';
import { Primitives } from './types';
interface PropertyInterface {
required?: boolean;
unique?: boolean;
hidden?: boolean;
type?: ColumnType;
}
interface EnumProperty {
enum: any[];
default?: Primitives;
}
export declare type DbEntity<T> = new () => T;
interface ManyToManyInterface<T> {
entity: (type?: any) => DbEntity<T>;
joinTableName: string;
foreignKey: string;
inverseForeignKey: string;
}
interface BelongsToInterface<T> {
entity: (type?: any) => DbEntity<T>;
inverse: string | ((object: T) => any);
pivotColumnName?: string;
}
interface HasManyInterface<T> {
entity: (type?: any) => DbEntity<T>;
inverse: string | ((object: T) => any);
}
export declare class DecoratorsClass {
/**
*
* @param spec
*/
id(): PropertyDecorator;
mongoId(): PropertyDecorator;
/**
*
* @param name
*/
entity(name: string): ClassDecorator;
/**
*
* @param params
*/
property(params?: PropertyInterface): PropertyDecorator;
/**
*
* @param e
*/
embed(e: any): PropertyDecorator;
/**
*
* @param e
*/
embedArray(e: any, params?: PropertyInterface): PropertyDecorator;
/**
*
* @param params
*/
stringArray(e: any, params?: PropertyInterface): PropertyDecorator;
/**
*
* @param e
* @param params
*/
Enum(e: EnumProperty, params?: PropertyInterface): PropertyDecorator;
/**
*
* @param e
*/
created(_e?: any): PropertyDecorator;
/**
*
* @param e
*/
updated(_e?: any): PropertyDecorator;
/**
*
* @param e
*/
deleted(_e?: any): PropertyDecorator;
/**
*
* @param e
*/
version(_e?: any): PropertyDecorator;
belongsToMany<T>({ entity, joinTableName, foreignKey, inverseForeignKey }: ManyToManyInterface<T>): PropertyDecorator;
belongsTo<T>({ entity, inverse, pivotColumnName }: BelongsToInterface<T>): PropertyDecorator;
hasMany<T>({ entity, inverse }: HasManyInterface<T>): PropertyDecorator;
}
export declare const f: DecoratorsClass;
export {};