Completed
Push — master ( d362a9...56faa4 )
by Mark
14s queued 11s
created

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

Complexity

Total Complexity 4
Complexity/F 2

Size

Lines of Code 43
Function Count 2

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 28
dl 0
loc 43
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
/**
5
 *
6
 */
7
export default class ForeignKey extends Field {
8
9
    private _foreignKey: string;
10
11
    private relation: Relation;
12
13
    /**
14
     *
15
     * @param name
16
     * @param foreignKey
17
     */
18
    constructor(name, foreignKey = null) {
19
        super(name);
20
        this._foreignKey = name ?? foreignKey;
21
    }
22
23
    get foreignKey(): string {
24
        return this._foreignKey;
25
    }
26
27
    get value() {
28
        return this.$fieldValue;
29
    }
30
31
    set value(value) {
32
        this.$fieldValue = value;
33
    }
34
35
    setRelation(relation: Relation) {
36
        this.relation = relation;
37
        return this;
38
    }
39
40
    tableSetup(table) {
41
        table.registerIndex(this.foreignKey);
42
    }
43
}