UNPKG

2.14 kBTypeScriptView Raw
1import { ColumnMetadata } from "./ColumnMetadata";
2import { EntityMetadata } from "./EntityMetadata";
3import { NamingStrategyInterface } from "../naming-strategy/NamingStrategyInterface";
4import { DeferrableType } from "./types/DeferrableType";
5import { OnDeleteType } from "./types/OnDeleteType";
6import { OnUpdateType } from "./types/OnUpdateType";
7/**
8 * Contains all information about entity's foreign key.
9 */
10export declare class ForeignKeyMetadata {
11 /**
12 * Entity metadata where this foreign key is.
13 */
14 entityMetadata: EntityMetadata;
15 /**
16 * Entity metadata which this foreign key references.
17 */
18 referencedEntityMetadata: EntityMetadata;
19 /**
20 * Array of columns of this foreign key.
21 */
22 columns: ColumnMetadata[];
23 /**
24 * Array of referenced columns.
25 */
26 referencedColumns: ColumnMetadata[];
27 /**
28 * What to do with a relation on deletion of the row containing a foreign key.
29 */
30 onDelete?: OnDeleteType;
31 /**
32 * What to do with a relation on update of the row containing a foreign key.
33 */
34 onUpdate?: OnUpdateType;
35 /**
36 * When to check the constraints of a foreign key.
37 */
38 deferrable?: DeferrableType;
39 /**
40 * Gets the table name to which this foreign key is referenced.
41 */
42 referencedTablePath: string;
43 /**
44 * Gets foreign key name.
45 */
46 name: string;
47 /**
48 * Gets array of column names.
49 */
50 columnNames: string[];
51 /**
52 * Gets array of referenced column names.
53 */
54 referencedColumnNames: string[];
55 constructor(options: {
56 entityMetadata: EntityMetadata;
57 referencedEntityMetadata: EntityMetadata;
58 namingStrategy?: NamingStrategyInterface;
59 columns: ColumnMetadata[];
60 referencedColumns: ColumnMetadata[];
61 onDelete?: OnDeleteType;
62 onUpdate?: OnUpdateType;
63 deferrable?: DeferrableType;
64 });
65 /**
66 * Builds some depend foreign key properties.
67 * Must be called after all entity metadatas and their columns are built.
68 */
69 build(namingStrategy: NamingStrategyInterface): void;
70}