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