@syntropix/database 0.0.5 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +80 -80
- package/dist/core/dataClient.js +3 -0
- package/dist/core/syntropix.d.ts +1 -1
- package/dist/core/syntropix.js +2 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/types/basemodel.d.ts +4 -3
- package/dist/types/basemodel.js +36 -35
- package/dist/types/common.d.ts +32 -28
- package/dist/types/common.js +11 -12
- package/dist/types/data-type.d.ts +48 -38
- package/dist/types/data-type.js +17 -18
- package/dist/types/dto/table.d.ts +6 -6
- package/dist/types/field.d.ts +60 -41
- package/dist/types/field.js +35 -32
- package/dist/types/filter.d.ts +43 -44
- package/dist/types/filter.js +56 -41
- package/dist/types/requests.d.ts +25 -14
- package/dist/types/requests.js +6 -1
- package/package.json +2 -2
package/dist/types/common.d.ts
CHANGED
|
@@ -1,24 +1,25 @@
|
|
|
1
|
+
import { SortType } from './filter';
|
|
2
|
+
import { SyntropixDBAccessType } from './requests';
|
|
1
3
|
export declare enum ForeignKeyAction {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
Cascade = "Cascade",
|
|
5
|
+
Restrict = "Restrict",
|
|
6
|
+
SetNull = "SetNull",
|
|
7
|
+
NoAction = "NoAction",
|
|
8
|
+
SetDefault = "SetDefault"
|
|
7
9
|
}
|
|
8
10
|
export declare enum AggregateFunction {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
11
|
+
Count = "Count",
|
|
12
|
+
Sum = "Sum",
|
|
13
|
+
Avg = "Avg",
|
|
14
|
+
Min = "Min",
|
|
15
|
+
Max = "Max",
|
|
16
|
+
CountDistinct = "CountDistinct"
|
|
15
17
|
}
|
|
16
18
|
export interface Sort {
|
|
17
19
|
column: string;
|
|
18
|
-
direction:
|
|
20
|
+
direction: SortType;
|
|
19
21
|
}
|
|
20
22
|
export interface Join {
|
|
21
|
-
type: 'INNER' | 'LEFT' | 'RIGHT' | 'FULL';
|
|
22
23
|
table: string;
|
|
23
24
|
on: any;
|
|
24
25
|
}
|
|
@@ -31,21 +32,23 @@ export interface GroupBy {
|
|
|
31
32
|
columns: string[];
|
|
32
33
|
}
|
|
33
34
|
export interface ForeignKey {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
35
|
+
name?: string;
|
|
36
|
+
fromTable: string;
|
|
37
|
+
fromColumn: string;
|
|
38
|
+
toTable: string;
|
|
39
|
+
toColumn: string;
|
|
40
|
+
onDelete?: ForeignKeyAction;
|
|
41
|
+
onUpdate?: ForeignKeyAction;
|
|
40
42
|
}
|
|
41
43
|
export interface Column {
|
|
42
44
|
name: string;
|
|
43
|
-
|
|
45
|
+
columnType: string | Record<string, any>;
|
|
44
46
|
description?: string;
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
47
|
+
isPrimaryKey?: boolean;
|
|
48
|
+
isNullable?: boolean;
|
|
49
|
+
autoIncrement?: boolean;
|
|
48
50
|
default?: any;
|
|
51
|
+
defaultAccess?: SyntropixDBAccessType;
|
|
49
52
|
}
|
|
50
53
|
export interface Index {
|
|
51
54
|
name: string;
|
|
@@ -56,16 +59,17 @@ export interface SyntropixDBColumn {
|
|
|
56
59
|
id: string;
|
|
57
60
|
name: string;
|
|
58
61
|
description: string;
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
62
|
+
columnType: string | Record<string, any>;
|
|
63
|
+
isNullable: boolean;
|
|
64
|
+
isPrimaryKey: boolean;
|
|
65
|
+
autoIncrement: boolean;
|
|
63
66
|
default?: any;
|
|
67
|
+
defaultAccess?: SyntropixDBAccessType;
|
|
64
68
|
}
|
|
65
69
|
export interface SyntropixDBTable {
|
|
66
70
|
id: string;
|
|
67
71
|
name: string;
|
|
68
72
|
description: string;
|
|
69
|
-
|
|
73
|
+
createdAt: Date;
|
|
70
74
|
columns: SyntropixDBColumn[];
|
|
71
75
|
}
|
package/dist/types/common.js
CHANGED
|
@@ -1,18 +1,17 @@
|
|
|
1
|
-
// Common types used across the SDK
|
|
2
1
|
export var ForeignKeyAction;
|
|
3
2
|
(function (ForeignKeyAction) {
|
|
4
|
-
ForeignKeyAction["
|
|
5
|
-
ForeignKeyAction["
|
|
6
|
-
ForeignKeyAction["
|
|
7
|
-
ForeignKeyAction["
|
|
8
|
-
ForeignKeyAction["
|
|
3
|
+
ForeignKeyAction["Cascade"] = "Cascade";
|
|
4
|
+
ForeignKeyAction["Restrict"] = "Restrict";
|
|
5
|
+
ForeignKeyAction["SetNull"] = "SetNull";
|
|
6
|
+
ForeignKeyAction["NoAction"] = "NoAction";
|
|
7
|
+
ForeignKeyAction["SetDefault"] = "SetDefault";
|
|
9
8
|
})(ForeignKeyAction || (ForeignKeyAction = {}));
|
|
10
9
|
export var AggregateFunction;
|
|
11
10
|
(function (AggregateFunction) {
|
|
12
|
-
AggregateFunction["
|
|
13
|
-
AggregateFunction["
|
|
14
|
-
AggregateFunction["
|
|
15
|
-
AggregateFunction["
|
|
16
|
-
AggregateFunction["
|
|
17
|
-
AggregateFunction["
|
|
11
|
+
AggregateFunction["Count"] = "Count";
|
|
12
|
+
AggregateFunction["Sum"] = "Sum";
|
|
13
|
+
AggregateFunction["Avg"] = "Avg";
|
|
14
|
+
AggregateFunction["Min"] = "Min";
|
|
15
|
+
AggregateFunction["Max"] = "Max";
|
|
16
|
+
AggregateFunction["CountDistinct"] = "CountDistinct";
|
|
18
17
|
})(AggregateFunction || (AggregateFunction = {}));
|
|
@@ -1,39 +1,49 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
type: string;
|
|
5
|
-
maxLength: number;
|
|
6
|
-
};
|
|
7
|
-
static readonly Text = "Text";
|
|
8
|
-
static readonly Boolean = "Boolean";
|
|
9
|
-
static readonly DateTime = "DateTime";
|
|
10
|
-
static readonly Timestamp = "Timestamp";
|
|
11
|
-
static readonly Date = "Date";
|
|
12
|
-
static readonly Json = "Json";
|
|
13
|
-
static readonly Uuid = "Uuid";
|
|
14
|
-
static readonly Double = "Double";
|
|
15
|
-
static readonly Vector: (dimensions: number) => {
|
|
16
|
-
type: string;
|
|
17
|
-
dimensions: number;
|
|
18
|
-
};
|
|
19
|
-
static readonly Array: (dataType: string | Record<string, any>) => {
|
|
20
|
-
type: string;
|
|
21
|
-
dataType: string | Record<string, any>;
|
|
22
|
-
};
|
|
23
|
-
static readonly Enum: (name: string, variants: string[]) => {
|
|
24
|
-
type: string;
|
|
25
|
-
name: string;
|
|
26
|
-
variants: string[];
|
|
27
|
-
};
|
|
28
|
-
static readonly Money: (precision: number, scale: number) => {
|
|
29
|
-
type: string;
|
|
30
|
-
precision: number;
|
|
31
|
-
scale: number;
|
|
32
|
-
};
|
|
33
|
-
static readonly Decimal: (precision: number, scale: number) => {
|
|
34
|
-
type: string;
|
|
35
|
-
precision: number;
|
|
36
|
-
scale: number;
|
|
37
|
-
};
|
|
1
|
+
interface StringType {
|
|
2
|
+
type: 'String';
|
|
3
|
+
maxLength: number;
|
|
38
4
|
}
|
|
39
|
-
|
|
5
|
+
interface VectorType {
|
|
6
|
+
type: 'Vector';
|
|
7
|
+
dimensions: number;
|
|
8
|
+
}
|
|
9
|
+
interface ArrayType {
|
|
10
|
+
type: 'Array';
|
|
11
|
+
dataType: string | Record<string, any>;
|
|
12
|
+
}
|
|
13
|
+
interface EnumType {
|
|
14
|
+
type: 'Enum';
|
|
15
|
+
name: string;
|
|
16
|
+
variants: string[];
|
|
17
|
+
}
|
|
18
|
+
interface MoneyType {
|
|
19
|
+
type: 'Money';
|
|
20
|
+
precision: number;
|
|
21
|
+
scale: number;
|
|
22
|
+
}
|
|
23
|
+
interface DecimalType {
|
|
24
|
+
type: 'Decimal';
|
|
25
|
+
precision: number;
|
|
26
|
+
scale: number;
|
|
27
|
+
}
|
|
28
|
+
export declare const ColumnType: {
|
|
29
|
+
readonly Integer: "Integer";
|
|
30
|
+
readonly String: (maxLength: number) => StringType;
|
|
31
|
+
readonly Text: "Text";
|
|
32
|
+
readonly Boolean: "Boolean";
|
|
33
|
+
readonly DateTime: "DateTime";
|
|
34
|
+
readonly Timestamp: "Timestamp";
|
|
35
|
+
readonly Date: "Date";
|
|
36
|
+
readonly Json: "Json";
|
|
37
|
+
readonly Uuid: "Uuid";
|
|
38
|
+
readonly Double: "Double";
|
|
39
|
+
readonly Vector: (dimensions: number) => VectorType;
|
|
40
|
+
readonly Array: (dataType: string | Record<string, any>) => ArrayType;
|
|
41
|
+
readonly Enum: (name: string, variants: string[]) => EnumType;
|
|
42
|
+
readonly Money: (precision: number, scale: number) => MoneyType;
|
|
43
|
+
readonly Decimal: (precision: number, scale: number) => DecimalType;
|
|
44
|
+
};
|
|
45
|
+
type DataTypeMap = typeof ColumnType;
|
|
46
|
+
type DataTypeValues = DataTypeMap[keyof DataTypeMap];
|
|
47
|
+
type DataTypeReturnTypes = ReturnType<Extract<DataTypeValues, (...args: any[]) => any>>;
|
|
48
|
+
export type ColumnType = Exclude<DataTypeValues, (...args: any[]) => any> | DataTypeReturnTypes;
|
|
49
|
+
export {};
|
package/dist/types/data-type.js
CHANGED
|
@@ -1,20 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
export class DataType {
|
|
1
|
+
export const ColumnType = {
|
|
3
2
|
// Basic types
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
3
|
+
Integer: 'Integer',
|
|
4
|
+
String: (maxLength) => ({ type: 'String', maxLength }),
|
|
5
|
+
Text: 'Text',
|
|
6
|
+
Boolean: 'Boolean',
|
|
7
|
+
DateTime: 'DateTime',
|
|
8
|
+
Timestamp: 'Timestamp',
|
|
9
|
+
Date: 'Date',
|
|
10
|
+
Json: 'Json',
|
|
11
|
+
Uuid: 'Uuid',
|
|
12
|
+
Double: 'Double',
|
|
14
13
|
// Complex types
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
}
|
|
14
|
+
Vector: (dimensions) => ({ type: 'Vector', dimensions }),
|
|
15
|
+
Array: (dataType) => ({ type: 'Array', dataType }),
|
|
16
|
+
Enum: (name, variants) => ({ type: 'Enum', name, variants }),
|
|
17
|
+
Money: (precision, scale) => ({ type: 'Money', precision, scale }),
|
|
18
|
+
Decimal: (precision, scale) => ({ type: 'Decimal', precision, scale }),
|
|
19
|
+
};
|
|
@@ -7,16 +7,16 @@ export interface TableCreateResponse {
|
|
|
7
7
|
id: string;
|
|
8
8
|
name: string;
|
|
9
9
|
description: string;
|
|
10
|
-
|
|
10
|
+
createdAt: any;
|
|
11
11
|
columns: Column[];
|
|
12
|
-
|
|
12
|
+
foreignKeys: ForeignKey[];
|
|
13
13
|
indexes: Index[];
|
|
14
14
|
schema: string;
|
|
15
|
-
|
|
15
|
+
defaultAccess: string | null;
|
|
16
16
|
};
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
17
|
+
createdAt: any;
|
|
18
|
+
updatedAt: any;
|
|
19
|
+
createdBy: string;
|
|
20
20
|
metadata: Record<string, any>;
|
|
21
21
|
triggers: any[];
|
|
22
22
|
}
|
package/dist/types/field.d.ts
CHANGED
|
@@ -1,20 +1,23 @@
|
|
|
1
1
|
import { Column, ForeignKeyAction } from './common';
|
|
2
2
|
import { ColumnType } from './data-type';
|
|
3
|
+
import { SyntropixDBAccessType } from './requests';
|
|
3
4
|
export declare abstract class Field {
|
|
4
5
|
name: string;
|
|
5
6
|
description: string;
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
columnType: ColumnType;
|
|
8
|
+
isPrimaryKey: boolean;
|
|
9
|
+
isNullable: boolean;
|
|
10
|
+
autoIncrement: boolean;
|
|
10
11
|
default?: any;
|
|
12
|
+
defaultAccess?: SyntropixDBAccessType;
|
|
11
13
|
constructor(column_type: ColumnType, options?: {
|
|
12
14
|
name?: string;
|
|
13
15
|
description?: string;
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
16
|
+
isPrimaryKey?: boolean;
|
|
17
|
+
isNullable?: boolean;
|
|
18
|
+
autoIncrement?: boolean;
|
|
17
19
|
default?: any;
|
|
20
|
+
defaultAccess?: SyntropixDBAccessType;
|
|
18
21
|
});
|
|
19
22
|
into(): Column;
|
|
20
23
|
}
|
|
@@ -23,133 +26,149 @@ export declare class ForeignKeyField extends Field {
|
|
|
23
26
|
columnName: string;
|
|
24
27
|
onDelete: ForeignKeyAction;
|
|
25
28
|
onUpdate: ForeignKeyAction;
|
|
26
|
-
constructor(
|
|
29
|
+
constructor(columnType: ColumnType, tableName: string, columnName: string, options?: {
|
|
27
30
|
onDelete?: ForeignKeyAction;
|
|
28
31
|
onUpdate?: ForeignKeyAction;
|
|
29
32
|
description?: string;
|
|
30
|
-
|
|
31
|
-
|
|
33
|
+
isPrimaryKey?: boolean;
|
|
34
|
+
isNullable?: boolean;
|
|
32
35
|
default?: any;
|
|
36
|
+
defaultAccess?: SyntropixDBAccessType;
|
|
33
37
|
});
|
|
34
38
|
}
|
|
35
39
|
export declare class StringField extends Field {
|
|
36
40
|
constructor(maxLength: number, options?: {
|
|
37
41
|
description?: string;
|
|
38
|
-
|
|
39
|
-
|
|
42
|
+
isPrimaryKey?: boolean;
|
|
43
|
+
isNullable?: boolean;
|
|
40
44
|
default?: string;
|
|
45
|
+
defaultAccess?: SyntropixDBAccessType;
|
|
41
46
|
});
|
|
42
47
|
}
|
|
43
48
|
export declare class TextField extends Field {
|
|
44
49
|
constructor(options?: {
|
|
45
50
|
description?: string;
|
|
46
|
-
|
|
47
|
-
|
|
51
|
+
isPrimaryKey?: boolean;
|
|
52
|
+
isNullable?: boolean;
|
|
48
53
|
default?: string;
|
|
54
|
+
defaultAccess?: SyntropixDBAccessType;
|
|
49
55
|
});
|
|
50
56
|
}
|
|
51
57
|
export declare class IntegerField extends Field {
|
|
52
58
|
constructor(options?: {
|
|
53
59
|
description?: string;
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
60
|
+
isPrimaryKey?: boolean;
|
|
61
|
+
isNullable?: boolean;
|
|
62
|
+
autoIncrement?: boolean;
|
|
57
63
|
default?: number;
|
|
64
|
+
defaultAccess?: SyntropixDBAccessType;
|
|
58
65
|
});
|
|
59
66
|
}
|
|
60
67
|
export declare class BooleanField extends Field {
|
|
61
68
|
constructor(options?: {
|
|
62
69
|
description?: string;
|
|
63
|
-
|
|
64
|
-
|
|
70
|
+
isPrimaryKey?: boolean;
|
|
71
|
+
isNullable?: boolean;
|
|
65
72
|
default?: boolean;
|
|
73
|
+
defaultAccess?: SyntropixDBAccessType;
|
|
66
74
|
});
|
|
67
75
|
}
|
|
68
76
|
export declare class DateTimeField extends Field {
|
|
69
77
|
constructor(options?: {
|
|
70
78
|
description?: string;
|
|
71
|
-
|
|
72
|
-
|
|
79
|
+
isPrimaryKey?: boolean;
|
|
80
|
+
isNullable?: boolean;
|
|
73
81
|
default?: Date;
|
|
82
|
+
defaultAccess?: SyntropixDBAccessType;
|
|
74
83
|
});
|
|
75
84
|
}
|
|
76
85
|
export declare class TimestampField extends Field {
|
|
77
86
|
constructor(options?: {
|
|
78
87
|
description?: string;
|
|
79
|
-
|
|
80
|
-
|
|
88
|
+
isPrimaryKey?: boolean;
|
|
89
|
+
isNullable?: boolean;
|
|
81
90
|
default?: Date;
|
|
91
|
+
defaultAccess?: SyntropixDBAccessType;
|
|
82
92
|
});
|
|
83
93
|
}
|
|
84
94
|
export declare class DateField extends Field {
|
|
85
95
|
constructor(options?: {
|
|
86
96
|
description?: string;
|
|
87
|
-
|
|
88
|
-
|
|
97
|
+
isPrimaryKey?: boolean;
|
|
98
|
+
isNullable?: boolean;
|
|
89
99
|
default?: Date;
|
|
100
|
+
defaultAccess?: SyntropixDBAccessType;
|
|
90
101
|
});
|
|
91
102
|
}
|
|
92
103
|
export declare class JsonField extends Field {
|
|
93
104
|
constructor(options?: {
|
|
94
105
|
description?: string;
|
|
95
|
-
|
|
96
|
-
|
|
106
|
+
isPrimaryKey?: boolean;
|
|
107
|
+
isNullable?: boolean;
|
|
97
108
|
default?: Record<string, any>;
|
|
109
|
+
defaultAccess?: SyntropixDBAccessType;
|
|
98
110
|
});
|
|
99
111
|
}
|
|
100
112
|
export declare class UuidField extends Field {
|
|
101
113
|
constructor(options?: {
|
|
102
114
|
description?: string;
|
|
103
|
-
|
|
104
|
-
|
|
115
|
+
isPrimaryKey?: boolean;
|
|
116
|
+
isNullable?: boolean;
|
|
105
117
|
default?: string;
|
|
118
|
+
defaultAccess?: SyntropixDBAccessType;
|
|
106
119
|
});
|
|
107
120
|
}
|
|
108
121
|
export declare class VectorField extends Field {
|
|
109
122
|
constructor(dimensions: number, options?: {
|
|
110
123
|
description?: string;
|
|
111
|
-
|
|
112
|
-
|
|
124
|
+
isPrimaryKey?: boolean;
|
|
125
|
+
isNullable?: boolean;
|
|
113
126
|
default?: number[];
|
|
127
|
+
defaultAccess?: SyntropixDBAccessType;
|
|
114
128
|
});
|
|
115
129
|
}
|
|
116
130
|
export declare class ArrayField extends Field {
|
|
117
131
|
constructor(dataType: ColumnType, options?: {
|
|
118
132
|
description?: string;
|
|
119
|
-
|
|
120
|
-
|
|
133
|
+
isPrimaryKey?: boolean;
|
|
134
|
+
isNullable?: boolean;
|
|
121
135
|
default?: any[];
|
|
136
|
+
defaultAccess?: SyntropixDBAccessType;
|
|
122
137
|
});
|
|
123
138
|
}
|
|
124
139
|
export declare class EnumField extends Field {
|
|
125
140
|
constructor(name: string, variants: string[], options?: {
|
|
126
141
|
description?: string;
|
|
127
|
-
|
|
128
|
-
|
|
142
|
+
isPrimaryKey?: boolean;
|
|
143
|
+
isNullable?: boolean;
|
|
129
144
|
default?: string;
|
|
145
|
+
defaultAccess?: SyntropixDBAccessType;
|
|
130
146
|
});
|
|
131
147
|
}
|
|
132
148
|
export declare class MoneyField extends Field {
|
|
133
149
|
constructor(precision: number, scale: number, options?: {
|
|
134
150
|
description?: string;
|
|
135
|
-
|
|
136
|
-
|
|
151
|
+
isPrimaryKey?: boolean;
|
|
152
|
+
isNullable?: boolean;
|
|
137
153
|
default?: number;
|
|
154
|
+
defaultAccess?: SyntropixDBAccessType;
|
|
138
155
|
});
|
|
139
156
|
}
|
|
140
157
|
export declare class DecimalField extends Field {
|
|
141
158
|
constructor(precision: number, scale: number, options?: {
|
|
142
159
|
description?: string;
|
|
143
|
-
|
|
144
|
-
|
|
160
|
+
isPrimaryKey?: boolean;
|
|
161
|
+
isNullable?: boolean;
|
|
145
162
|
default?: number;
|
|
163
|
+
defaultAccess?: SyntropixDBAccessType;
|
|
146
164
|
});
|
|
147
165
|
}
|
|
148
166
|
export declare class DoubleField extends Field {
|
|
149
167
|
constructor(options?: {
|
|
150
168
|
description?: string;
|
|
151
|
-
|
|
152
|
-
|
|
169
|
+
isPrimaryKey?: boolean;
|
|
170
|
+
isNullable?: boolean;
|
|
153
171
|
default?: number;
|
|
172
|
+
defaultAccess?: SyntropixDBAccessType;
|
|
154
173
|
});
|
|
155
174
|
}
|
package/dist/types/field.js
CHANGED
|
@@ -1,32 +1,35 @@
|
|
|
1
1
|
// Field definitions for ORM
|
|
2
2
|
import { ForeignKeyAction } from './common';
|
|
3
|
-
import {
|
|
3
|
+
import { ColumnType } from './data-type';
|
|
4
4
|
export class Field {
|
|
5
5
|
name = '';
|
|
6
6
|
description = '';
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
7
|
+
columnType;
|
|
8
|
+
isPrimaryKey = false;
|
|
9
|
+
isNullable = false;
|
|
10
|
+
autoIncrement = false;
|
|
11
11
|
default;
|
|
12
|
+
defaultAccess;
|
|
12
13
|
constructor(column_type, options = {}) {
|
|
13
|
-
this.
|
|
14
|
+
this.columnType = column_type;
|
|
14
15
|
this.name = options.name?.toLowerCase() || '';
|
|
15
16
|
this.description = options.description || '';
|
|
16
|
-
this.
|
|
17
|
-
this.
|
|
18
|
-
this.
|
|
17
|
+
this.isPrimaryKey = options.isPrimaryKey || false;
|
|
18
|
+
this.isNullable = options.isNullable || false;
|
|
19
|
+
this.autoIncrement = options.autoIncrement || false;
|
|
19
20
|
this.default = options.default;
|
|
21
|
+
this.defaultAccess = options.defaultAccess;
|
|
20
22
|
}
|
|
21
23
|
into() {
|
|
22
24
|
return {
|
|
23
25
|
name: this.name,
|
|
24
|
-
|
|
26
|
+
columnType: this.columnType,
|
|
25
27
|
description: this.description,
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
28
|
+
isPrimaryKey: this.isPrimaryKey,
|
|
29
|
+
isNullable: this.isNullable,
|
|
30
|
+
autoIncrement: this.autoIncrement,
|
|
29
31
|
default: this.default,
|
|
32
|
+
defaultAccess: this.defaultAccess,
|
|
30
33
|
};
|
|
31
34
|
}
|
|
32
35
|
}
|
|
@@ -35,86 +38,86 @@ export class ForeignKeyField extends Field {
|
|
|
35
38
|
columnName;
|
|
36
39
|
onDelete;
|
|
37
40
|
onUpdate;
|
|
38
|
-
constructor(
|
|
39
|
-
super(
|
|
41
|
+
constructor(columnType, tableName, columnName, options = {}) {
|
|
42
|
+
super(columnType, options);
|
|
40
43
|
this.tableName = tableName;
|
|
41
44
|
this.columnName = columnName;
|
|
42
|
-
this.onDelete = options.onDelete || ForeignKeyAction.
|
|
43
|
-
this.onUpdate = options.onUpdate || ForeignKeyAction.
|
|
45
|
+
this.onDelete = options.onDelete || ForeignKeyAction.Cascade;
|
|
46
|
+
this.onUpdate = options.onUpdate || ForeignKeyAction.Cascade;
|
|
44
47
|
}
|
|
45
48
|
}
|
|
46
49
|
export class StringField extends Field {
|
|
47
50
|
constructor(maxLength, options = {}) {
|
|
48
|
-
super(
|
|
51
|
+
super(ColumnType.String(maxLength), options);
|
|
49
52
|
}
|
|
50
53
|
}
|
|
51
54
|
export class TextField extends Field {
|
|
52
55
|
constructor(options = {}) {
|
|
53
|
-
super(
|
|
56
|
+
super(ColumnType.Text, options);
|
|
54
57
|
}
|
|
55
58
|
}
|
|
56
59
|
export class IntegerField extends Field {
|
|
57
60
|
constructor(options = {}) {
|
|
58
|
-
super(
|
|
61
|
+
super(ColumnType.Integer, options);
|
|
59
62
|
}
|
|
60
63
|
}
|
|
61
64
|
export class BooleanField extends Field {
|
|
62
65
|
constructor(options = {}) {
|
|
63
|
-
super(
|
|
66
|
+
super(ColumnType.Boolean, options);
|
|
64
67
|
}
|
|
65
68
|
}
|
|
66
69
|
export class DateTimeField extends Field {
|
|
67
70
|
constructor(options = {}) {
|
|
68
|
-
super(
|
|
71
|
+
super(ColumnType.DateTime, options);
|
|
69
72
|
}
|
|
70
73
|
}
|
|
71
74
|
export class TimestampField extends Field {
|
|
72
75
|
constructor(options = {}) {
|
|
73
|
-
super(
|
|
76
|
+
super(ColumnType.Timestamp, options);
|
|
74
77
|
}
|
|
75
78
|
}
|
|
76
79
|
export class DateField extends Field {
|
|
77
80
|
constructor(options = {}) {
|
|
78
|
-
super(
|
|
81
|
+
super(ColumnType.Date, options);
|
|
79
82
|
}
|
|
80
83
|
}
|
|
81
84
|
export class JsonField extends Field {
|
|
82
85
|
constructor(options = {}) {
|
|
83
|
-
super(
|
|
86
|
+
super(ColumnType.Json, options);
|
|
84
87
|
}
|
|
85
88
|
}
|
|
86
89
|
export class UuidField extends Field {
|
|
87
90
|
constructor(options = {}) {
|
|
88
|
-
super(
|
|
91
|
+
super(ColumnType.Uuid, options);
|
|
89
92
|
}
|
|
90
93
|
}
|
|
91
94
|
export class VectorField extends Field {
|
|
92
95
|
constructor(dimensions, options = {}) {
|
|
93
|
-
super(
|
|
96
|
+
super(ColumnType.Vector(dimensions), options);
|
|
94
97
|
}
|
|
95
98
|
}
|
|
96
99
|
export class ArrayField extends Field {
|
|
97
100
|
constructor(dataType, options = {}) {
|
|
98
|
-
super(
|
|
101
|
+
super(ColumnType.Array(dataType), options);
|
|
99
102
|
}
|
|
100
103
|
}
|
|
101
104
|
export class EnumField extends Field {
|
|
102
105
|
constructor(name, variants, options = {}) {
|
|
103
|
-
super(
|
|
106
|
+
super(ColumnType.Enum(name, variants), options);
|
|
104
107
|
}
|
|
105
108
|
}
|
|
106
109
|
export class MoneyField extends Field {
|
|
107
110
|
constructor(precision, scale, options = {}) {
|
|
108
|
-
super(
|
|
111
|
+
super(ColumnType.Money(precision, scale), options);
|
|
109
112
|
}
|
|
110
113
|
}
|
|
111
114
|
export class DecimalField extends Field {
|
|
112
115
|
constructor(precision, scale, options = {}) {
|
|
113
|
-
super(
|
|
116
|
+
super(ColumnType.Decimal(precision, scale), options);
|
|
114
117
|
}
|
|
115
118
|
}
|
|
116
119
|
export class DoubleField extends Field {
|
|
117
120
|
constructor(options = {}) {
|
|
118
|
-
super(
|
|
121
|
+
super(ColumnType.Double, options);
|
|
119
122
|
}
|
|
120
123
|
}
|