333
schangxiang@126.com
2025-09-19 18966e02fb573c7e2bb0c6426ed792b38b910940
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
/**
 * Contains all information about entity's foreign key.
 */
var ForeignKeyMetadata = /** @class */ (function () {
    // ---------------------------------------------------------------------
    // Constructor
    // ---------------------------------------------------------------------
    function ForeignKeyMetadata(options) {
        /**
         * Array of columns of this foreign key.
         */
        this.columns = [];
        /**
         * Array of referenced columns.
         */
        this.referencedColumns = [];
        /**
         * Gets array of column names.
         */
        this.columnNames = [];
        /**
         * Gets array of referenced column names.
         */
        this.referencedColumnNames = [];
        this.entityMetadata = options.entityMetadata;
        this.referencedEntityMetadata = options.referencedEntityMetadata;
        this.columns = options.columns;
        this.referencedColumns = options.referencedColumns;
        this.onDelete = options.onDelete || "NO ACTION";
        this.onUpdate = options.onUpdate || "NO ACTION";
        this.deferrable = options.deferrable;
        if (options.namingStrategy)
            this.build(options.namingStrategy);
    }
    // ---------------------------------------------------------------------
    // Public Methods
    // ---------------------------------------------------------------------
    /**
     * Builds some depend foreign key properties.
     * Must be called after all entity metadatas and their columns are built.
     */
    ForeignKeyMetadata.prototype.build = function (namingStrategy) {
        this.columnNames = this.columns.map(function (column) { return column.databaseName; });
        this.referencedColumnNames = this.referencedColumns.map(function (column) { return column.databaseName; });
        this.referencedTablePath = this.referencedEntityMetadata.tablePath;
        this.name = namingStrategy.foreignKeyName(this.entityMetadata.tablePath, this.columnNames);
    };
    return ForeignKeyMetadata;
}());
export { ForeignKeyMetadata };
 
//# sourceMappingURL=ForeignKeyMetadata.js.map