| Total Complexity | 4 |
| Complexity/F | 2 |
| Lines of Code | 43 |
| Function Count | 2 |
| Duplicated Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 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 | } |