UNPKG

1.8 kBTypeScriptView Raw
1import { ModelPersistenceEventCallback } from '../Types';
2/**
3 * Attribute index configuration
4 */
5export interface IModelAttributeIndex {
6 name: string;
7 unique?: boolean;
8 isSecondaryKey?: boolean;
9 secondaryKey?: string;
10}
11/**
12 * Model attribute options
13 */
14export interface IModelAttributeOptions {
15 name?: string;
16 type?: any;
17 typeName?: string;
18 isArray?: boolean;
19 primaryKey?: boolean;
20 secondaryKey?: boolean;
21 index?: IModelAttributeIndex;
22 transient?: boolean;
23}
24/**
25 * Options provided to model
26 * decorator annotation
27 */
28export interface IModelOptions {
29 clazzName?: string;
30 clazz?: any;
31 onlyMapDefinedAttributes?: boolean;
32 tableName?: string;
33 attrs?: IModelAttributeOptions[];
34 transientAttrs?: string[];
35 onPersistenceEvent?: ModelPersistenceEventCallback<any>;
36}
37/**
38 * Model key shape
39 */
40export interface IModelKey {
41}
42/**
43 * Model key value shape
44 */
45export interface IKeyValue {
46}
47export declare type TKeyValue = IKeyValue | string | number;
48/**
49 * Decorate a specified class, making it a
50 * PersistableModel
51 *
52 * Set process.env.DYNO_SKIP to true in order to skip
53 * decorations - useful in dual purpose classes,
54 * in webpack use DefinePlugin
55 *
56 * @param opts
57 */
58export declare function Model(opts?: IModelOptions): (constructor: Function) => void;
59/**
60 * Default value resolver
61 */
62export declare type DefaultValueFn = (o: any) => any;
63/**
64 * Default value decoration
65 */
66export declare function DefaultValue(defaultValueFn: DefaultValueFn): (target: any, propertyKey: string) => void;
67/**
68 * Decorator model attribute
69 *
70 * @param opts
71 * @returns {function(any, string): undefined}
72 * @constructor
73 */
74export declare function Attribute(opts?: IModelAttributeOptions): (target: any, propertyKey: string) => void;