src/Store/Model/Field/ForeignKey.ts   A
last analyzed

Complexity

Total Complexity 4
Complexity/F 2

Size

Lines of Code 35
Function Count 2

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 28
dl 0
loc 35
rs 10
c 0
b 0
f 0
wmc 4
mnd 2
bc 2
fnc 2
bpm 1
cpm 2
noi 0

2 Functions

Rating   Name   Duplication   Size   Complexity  
A ForeignKey.setRelation 0 4 3
A ForeignKey.tableSetup 0 3 1
1
import Field from "../Field";
2
import Relation from "../Relation";
3
4
export default class ForeignKey extends Field {
5
6
    private _foreignKey: string;
7
8
    private relation: Relation;
9
10
    constructor(name, foreignKey = null) {
11
        super(name);
12
        this._foreignKey = name ?? foreignKey;
13
    }
14
15
    get foreignKey(): string {
16
        return this._foreignKey;
17
    }
18
19
    get value() {
20
        return this.$fieldValue;
21
    }
22
23
    set value(newValue: unknown) {
24
        this.$fieldValue = newValue;
25
    }
26
27
    setRelation(relation: Relation) {
28
        this.relation = relation;
29
        return this;
30
    }
31
32
    tableSetup(table) {
33
        table.registerIndex(this.foreignKey);
34
    }
35
}