-
Notifications
You must be signed in to change notification settings - Fork 1
/
mysql-column.entity.ts
49 lines (35 loc) · 1.25 KB
/
mysql-column.entity.ts
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
import { Table, Column, OneToMany } from '../../../metadata/';
import { YesNoConverter } from '../../../converter/';
import { IsPrimaryConverter, IsGeneratedConverter,
HasDefaultConverter, MySQLKeyColumnUsage } from '../../';
@Table({name: 'COLUMNS'})
export class MySQLColumn {
@Column({name: 'COLUMN_NAME', isPrimary: true})
name: string;
@Column({name: 'TABLE_NAME', isPrimary: true})
tableName: string;
@Column({name: 'TABLE_SCHEMA', isPrimary: true})
schema: string;
@Column({name: 'DATA_TYPE'})
dataType: string;
@Column({name: 'COLUMN_TYPE'})
columnType: string;
@Column({name: 'IS_NULLABLE', converter: new YesNoConverter()})
isNullable: boolean;
@Column({name: 'CHARACTER_MAXIMUM_LENGTH'})
maxLength: number;
@Column({name: 'COLUMN_KEY', converter: new IsPrimaryConverter()})
isPrimary: boolean;
@Column({name: 'COLUMN_DEFAULT', converter: new HasDefaultConverter()})
hasDefault: boolean;
@Column({name: 'EXTRA', converter: new IsGeneratedConverter()})
isGenerated: boolean;
@OneToMany<MySQLColumn, MySQLKeyColumnUsage>(
() => MySQLKeyColumnUsage,
(c, fk) => [
[c.tableName, fk.tableName],
[c.schema, fk.schema],
[c.name, fk.columnName]
])
keyColumnUsage: MySQLKeyColumnUsage[];
}