1 | import { JoinColumnOptions } from "../decorator/options/JoinColumnOptions";
|
2 | import { RelationType } from "../metadata/types/RelationTypes";
|
3 | import { JoinTableMultipleColumnsOptions } from "../decorator/options/JoinTableMultipleColumnsOptions";
|
4 | import { DeferrableType } from "../metadata/types/DeferrableType";
|
5 | import { OnDeleteType } from "../metadata/types/OnDeleteType";
|
6 | import { OnUpdateType } from "../metadata/types/OnUpdateType";
|
7 | import { JoinTableOptions } from "../index";
|
8 | export interface EntitySchemaRelationOptions {
|
9 | /**
|
10 | * Indicates with which entity this relation is made.
|
11 | */
|
12 | target: Function | string;
|
13 | /**
|
14 | * Type of relation. Can be one of the value of the RelationTypes class.
|
15 | */
|
16 | type: RelationType;
|
17 | /**
|
18 | * Inverse side of the relation.
|
19 | */
|
20 | inverseSide?: string;
|
21 | /**
|
22 | * Indicates if this relation will be lazily loaded.
|
23 | */
|
24 | lazy?: boolean;
|
25 | /**
|
26 | * Indicates if this relation will be eagerly loaded.
|
27 | */
|
28 | eager?: boolean;
|
29 | /**
|
30 | * Indicates if persistence is enabled for the relation.
|
31 | * By default its enabled, but if you want to avoid any changes in the relation to be reflected in the database you can disable it.
|
32 | * If its disabled you can only change a relation from inverse side of a relation or using relation query builder functionality.
|
33 | * This is useful for performance optimization since its disabling avoid multiple extra queries during entity save.
|
34 | */
|
35 | persistence?: boolean;
|
36 | /**
|
37 | * Indicates if this relation will be a primary key.
|
38 | * Can be used only for many-to-one and owner one-to-one relations.
|
39 | */
|
40 | primary?: boolean;
|
41 | /**
|
42 | * Join table options of this column. If set to true then it simply means that it has a join table.
|
43 | */
|
44 | joinTable?: boolean | JoinTableOptions | JoinTableMultipleColumnsOptions;
|
45 | /**
|
46 | * Join column options of this column. If set to true then it simply means that it has a join column.
|
47 | */
|
48 | joinColumn?: boolean | JoinColumnOptions;
|
49 | /**
|
50 | * Indicates if this is a parent (can be only many-to-one relation) relation in the tree tables.
|
51 | */
|
52 | treeParent?: boolean;
|
53 | /**
|
54 | * Indicates if this is a children (can be only one-to-many relation) relation in the tree tables.
|
55 | */
|
56 | treeChildren?: boolean;
|
57 | /**
|
58 | * If set to true then it means that related object can be allowed to be inserted / updated / removed to the db.
|
59 | * This is option a shortcut if you would like to set cascadeInsert, cascadeUpdate and cascadeRemove to true.
|
60 | */
|
61 | cascade?: boolean | ("insert" | "update" | "remove")[];
|
62 | /**
|
63 | * Default database value.
|
64 | */
|
65 | default?: any;
|
66 | /**
|
67 | * Indicates if relation column value can be nullable or not.
|
68 | */
|
69 | nullable?: boolean;
|
70 | /**
|
71 | * Database cascade action on delete.
|
72 | */
|
73 | onDelete?: OnDeleteType;
|
74 | /**
|
75 | * Database cascade action on update.
|
76 | */
|
77 | onUpdate?: OnUpdateType;
|
78 | /**
|
79 | * Indicate if foreign key constraints can be deferred.
|
80 | */
|
81 | deferrable?: DeferrableType;
|
82 | }
|