namirasoft-node-sequelize 1.4.11 → 1.4.13
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/dist/BaseSequelizeTable.d.ts +5 -6
- package/dist/BaseSequelizeTable.js +6 -7
- package/dist/BaseSequelizeTable.js.map +1 -1
- package/package.json +4 -4
- package/src/BaseDB2Database.ts +12 -12
- package/src/BaseFilterItemBuilderSequelize.ts +123 -123
- package/src/BaseMSSQLDatabase.ts +12 -12
- package/src/BaseMariaDBDatabase.ts +12 -12
- package/src/BaseMySqlDatabase.ts +12 -12
- package/src/BaseOracleDatabase.ts +12 -12
- package/src/BasePostgreSQLDatabase.ts +19 -19
- package/src/BaseSQLiteDatabase.ts +12 -12
- package/src/BaseSequelizeDatabase.ts +165 -165
- package/src/BaseSequelizeModel.ts +4 -4
- package/src/BaseSequelizeModelAttributeColumnOptions.ts +10 -10
- package/src/BaseSequelizeModelAttributes.ts +5 -5
- package/src/BaseSequelizeTable.ts +272 -274
- package/src/BaseSnowFlakeDatabase.ts +12 -12
- package/src/index.ts +13 -13
|
@@ -1,275 +1,273 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
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
|
-
if (name
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
let
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
let
|
|
89
|
-
let
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
if (type instanceof DataTypes.
|
|
127
|
-
return new
|
|
128
|
-
else if (type instanceof DataTypes.
|
|
129
|
-
return new
|
|
130
|
-
else if (type instanceof DataTypes.
|
|
131
|
-
return new
|
|
132
|
-
else if (type instanceof DataTypes.
|
|
133
|
-
return new
|
|
134
|
-
else if (type instanceof DataTypes.
|
|
135
|
-
return new
|
|
136
|
-
else if (type
|
|
137
|
-
return new
|
|
138
|
-
else if (this.
|
|
139
|
-
return new
|
|
140
|
-
else if (this.
|
|
141
|
-
return new
|
|
142
|
-
else if (this.
|
|
143
|
-
return new
|
|
144
|
-
else if (this.
|
|
145
|
-
return new
|
|
146
|
-
else if (this.
|
|
147
|
-
return new StringSchema(required,
|
|
148
|
-
else if (
|
|
149
|
-
return new StringSchema(required, null,
|
|
150
|
-
else if (type instanceof DataTypes.
|
|
151
|
-
return new
|
|
152
|
-
else if (type instanceof DataTypes.
|
|
153
|
-
return new
|
|
154
|
-
else if (type instanceof DataTypes.
|
|
155
|
-
return new
|
|
156
|
-
else if (type
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
if (tags_type == "
|
|
169
|
-
return new
|
|
170
|
-
if (tags_type == "
|
|
171
|
-
return new
|
|
172
|
-
if (tags_type == "
|
|
173
|
-
return new ArraySchema(required, [new
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
if (
|
|
214
|
-
options = {
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
if (options.
|
|
221
|
-
options.
|
|
222
|
-
if (options.
|
|
223
|
-
options.
|
|
224
|
-
if (options.
|
|
225
|
-
options.
|
|
226
|
-
if (options.
|
|
227
|
-
options.
|
|
228
|
-
if (options.
|
|
229
|
-
options.
|
|
230
|
-
if (options.
|
|
231
|
-
options.
|
|
232
|
-
if (options.
|
|
233
|
-
options.
|
|
234
|
-
if (options.
|
|
235
|
-
options.
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
return await this.model.findAndCountAll({ ...options, where, distinct: true, subQuery: false, transaction: trx });
|
|
274
|
-
}
|
|
1
|
+
import { BaseMetaColumn, BaseMetaTable, BaseUUID, NamingConvention, SortItem } from "namirasoft-core";
|
|
2
|
+
import { BaseTable } from "namirasoft-node";
|
|
3
|
+
import { AnySchema, ArraySchema, BaseTypeSchema, BigIntSchema, BoolSchema, DateSchema, DateTimeSchema, DecimalSchema, DoubleSchema, EnumSchema, FloatSchema, IntegerSchema, MediumIntSchema, RealSchema, SmallIntSchema, StringSchema, TimeSchema, TinyIntSchema, TypeSchema, VariableSchema } from "namirasoft-schema";
|
|
4
|
+
import { Attributes, DataTypes, FindOptions, ModelCtor, ModelOptions, Transaction, WhereOptions } from "sequelize";
|
|
5
|
+
import { BaseSequelizeDatabase } from "./BaseSequelizeDatabase";
|
|
6
|
+
import { BaseSequelizeModel } from "./BaseSequelizeModel";
|
|
7
|
+
import { BaseSequelizeModelAttributeColumnOptions } from "./BaseSequelizeModelAttributeColumnOptions";
|
|
8
|
+
import { BaseSequelizeModelAttributes } from "./BaseSequelizeModelAttributes";
|
|
9
|
+
|
|
10
|
+
export abstract class BaseSequelizeTable<D extends BaseSequelizeDatabase, M extends BaseSequelizeModel> extends BaseTable<D, BaseSequelizeModelAttributeColumnOptions>
|
|
11
|
+
{
|
|
12
|
+
model!: ModelCtor<M>;
|
|
13
|
+
attributes!: BaseSequelizeModelAttributes<M, Attributes<M>>;
|
|
14
|
+
constructor(database: D)
|
|
15
|
+
{
|
|
16
|
+
super(database);
|
|
17
|
+
}
|
|
18
|
+
override getName(): string
|
|
19
|
+
{
|
|
20
|
+
return this.model.name;
|
|
21
|
+
}
|
|
22
|
+
protected override getExamples()
|
|
23
|
+
{
|
|
24
|
+
let ans: { [name: string]: string } = super.getExamples();
|
|
25
|
+
let add = (name: string, uuid: BaseUUID) =>
|
|
26
|
+
{
|
|
27
|
+
if (uuid.short)
|
|
28
|
+
ans[name] = uuid.new();
|
|
29
|
+
};
|
|
30
|
+
this.forEachColumn((name, column) =>
|
|
31
|
+
{
|
|
32
|
+
if (this.isChar(column.type))
|
|
33
|
+
{
|
|
34
|
+
if (name == "id")
|
|
35
|
+
add(name, this.uuid);
|
|
36
|
+
else if (name.endsWith("_id"))
|
|
37
|
+
{
|
|
38
|
+
try
|
|
39
|
+
{
|
|
40
|
+
let t = this.database.getTable(name.replace(/_id$/gm, "")) as BaseTable<D, any>;
|
|
41
|
+
add(name, t.uuid);
|
|
42
|
+
} catch (error)
|
|
43
|
+
{
|
|
44
|
+
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
return ans;
|
|
50
|
+
}
|
|
51
|
+
override getSecureColumns(): string[]
|
|
52
|
+
{
|
|
53
|
+
let columns = super.getSecureColumns();
|
|
54
|
+
return ["deletedAt", "deleted_at", ...columns]
|
|
55
|
+
}
|
|
56
|
+
override getReadOnlyColumns(): string[]
|
|
57
|
+
{
|
|
58
|
+
let columns = super.getReadOnlyColumns();
|
|
59
|
+
return ["id", "created_at", "updated_at", "createdAt", "updatedAt", ...columns];
|
|
60
|
+
}
|
|
61
|
+
private getModelAllAttributes()
|
|
62
|
+
{
|
|
63
|
+
let dateAttributes: BaseSequelizeModelAttributes<
|
|
64
|
+
any,
|
|
65
|
+
Attributes<any>
|
|
66
|
+
> = {
|
|
67
|
+
created_at: { type: DataTypes.DATE, allowNull: false },
|
|
68
|
+
updated_at: { type: DataTypes.DATE, allowNull: false },
|
|
69
|
+
};
|
|
70
|
+
return { ... this.attributes, ...dateAttributes };
|
|
71
|
+
}
|
|
72
|
+
public override getColumnOption(name: string)
|
|
73
|
+
{
|
|
74
|
+
let att = this.getModelAllAttributes();
|
|
75
|
+
return att[name] as BaseSequelizeModelAttributeColumnOptions;
|
|
76
|
+
}
|
|
77
|
+
public override forEachColumn(handler: (name: string, column: BaseSequelizeModelAttributeColumnOptions) => void)
|
|
78
|
+
{
|
|
79
|
+
let att = this.getModelAllAttributes();
|
|
80
|
+
let keys = Object.keys(att);
|
|
81
|
+
for (let i = 0; i < keys.length; i++)
|
|
82
|
+
handler(keys[i], this.getColumnOption(keys[i]));
|
|
83
|
+
}
|
|
84
|
+
public override getColumn(name: string): BaseMetaColumn
|
|
85
|
+
{
|
|
86
|
+
let option = this.getColumnOption(name);
|
|
87
|
+
let table_name = this.getName();
|
|
88
|
+
let table = new BaseMetaTable(null, table_name, table_name);
|
|
89
|
+
let type = option.type as any;
|
|
90
|
+
try
|
|
91
|
+
{
|
|
92
|
+
if (typeof (type) == "function")
|
|
93
|
+
type = type();
|
|
94
|
+
type = type + "";
|
|
95
|
+
} catch (error)
|
|
96
|
+
{
|
|
97
|
+
type = "Enum";
|
|
98
|
+
}
|
|
99
|
+
let column = new BaseMetaColumn(table, name, name, type, option.allowNull != true);
|
|
100
|
+
return column;
|
|
101
|
+
}
|
|
102
|
+
protected override getTypeSchema(name: string, option: BaseSequelizeModelAttributeColumnOptions): BaseTypeSchema
|
|
103
|
+
{
|
|
104
|
+
let required = !(option.allowNull ?? true);
|
|
105
|
+
let type = option.type as any;
|
|
106
|
+
try
|
|
107
|
+
{
|
|
108
|
+
if (typeof (type) == "function")
|
|
109
|
+
type = type();
|
|
110
|
+
} catch (error)
|
|
111
|
+
{
|
|
112
|
+
}
|
|
113
|
+
let type_name = "";
|
|
114
|
+
try
|
|
115
|
+
{
|
|
116
|
+
type_name = type + "";
|
|
117
|
+
} catch (error)
|
|
118
|
+
{
|
|
119
|
+
type_name = "Enum";
|
|
120
|
+
}
|
|
121
|
+
let min: number | null = (option.validate?.min ?? null) as number | null;
|
|
122
|
+
let max: number | null = (option.validate?.max ?? null) as number | null;
|
|
123
|
+
/* VariableType */
|
|
124
|
+
if (type instanceof DataTypes.BOOLEAN)
|
|
125
|
+
return new BoolSchema(required);
|
|
126
|
+
else if (type instanceof DataTypes.TINYINT)
|
|
127
|
+
return new TinyIntSchema(required, min, max);
|
|
128
|
+
else if (type instanceof DataTypes.SMALLINT)
|
|
129
|
+
return new SmallIntSchema(required, min, max);
|
|
130
|
+
else if (type instanceof DataTypes.MEDIUMINT)
|
|
131
|
+
return new MediumIntSchema(required, min, max);
|
|
132
|
+
else if (type instanceof DataTypes.INTEGER)
|
|
133
|
+
return new IntegerSchema(required, min, max);
|
|
134
|
+
else if (type instanceof DataTypes.BIGINT)
|
|
135
|
+
return new BigIntSchema(required, min, max);
|
|
136
|
+
else if (this.isFloat(type))
|
|
137
|
+
return new FloatSchema(required, type.options.decimals, min, max);
|
|
138
|
+
else if (this.isDouble(type))
|
|
139
|
+
return new DoubleSchema(required, type.options.decimals, min, max);
|
|
140
|
+
else if (this.isDecimal(type))
|
|
141
|
+
return new DecimalSchema(required, type.options.scale, min, max);
|
|
142
|
+
else if (this.isReal(type))
|
|
143
|
+
return new RealSchema(required, type.options.decimals, min, max);
|
|
144
|
+
else if (this.isChar(type))
|
|
145
|
+
return new StringSchema(required, type.options.length ?? type._length, type.options.length ?? type._length);
|
|
146
|
+
else if (this.isString(type))
|
|
147
|
+
return new StringSchema(required, null, type.options.length ?? type._length);
|
|
148
|
+
else if (type instanceof DataTypes.TEXT)
|
|
149
|
+
return new StringSchema(required, null, null);
|
|
150
|
+
else if (type instanceof DataTypes.DATE || type_name == "TIMESTAMP")
|
|
151
|
+
return new DateTimeSchema(required);
|
|
152
|
+
else if (type instanceof DataTypes.DATEONLY)
|
|
153
|
+
return new DateSchema(required);
|
|
154
|
+
else if (type instanceof DataTypes.TIME)
|
|
155
|
+
return new TimeSchema(required);
|
|
156
|
+
else if (this.isEnum(type))
|
|
157
|
+
{
|
|
158
|
+
let _name = NamingConvention.lower_case_underscore.convert(this.model.name + "_" + option.field, NamingConvention.Pascal_Case);
|
|
159
|
+
return new EnumSchema(_name, required, type.options.values);
|
|
160
|
+
}
|
|
161
|
+
else if (type instanceof DataTypes.JSON)
|
|
162
|
+
{
|
|
163
|
+
let tags_type = option.tags?.type;
|
|
164
|
+
if (tags_type)
|
|
165
|
+
{
|
|
166
|
+
if (tags_type == "BaseTypeSchema")
|
|
167
|
+
return new TypeSchema(required);
|
|
168
|
+
if (tags_type == "BaseVariableSchema")
|
|
169
|
+
return new VariableSchema(required);
|
|
170
|
+
if (tags_type == "BaseTypeSchema[]")
|
|
171
|
+
return new ArraySchema(required, [new TypeSchema(required)]);
|
|
172
|
+
if (tags_type == "BaseVariableSchema[]")
|
|
173
|
+
return new ArraySchema(required, [new VariableSchema(required)]);
|
|
174
|
+
}
|
|
175
|
+
return new AnySchema(required);
|
|
176
|
+
}
|
|
177
|
+
throw new Error(`Unsupported datatype for name: '${name}' schema: '${option.type}'`);
|
|
178
|
+
}
|
|
179
|
+
protected isFloat(type: any): type is { options: { length: number, decimals: number } }
|
|
180
|
+
{
|
|
181
|
+
return type instanceof DataTypes.FLOAT;
|
|
182
|
+
}
|
|
183
|
+
protected isDouble(type: any): type is { options: { length: number, decimals: number } }
|
|
184
|
+
{
|
|
185
|
+
return type instanceof DataTypes.DOUBLE;
|
|
186
|
+
}
|
|
187
|
+
protected isDecimal(type: any): type is { options: { precision: number, scale: number } }
|
|
188
|
+
{
|
|
189
|
+
return type instanceof DataTypes.DECIMAL;
|
|
190
|
+
}
|
|
191
|
+
protected isReal(type: any): type is { options: { length: number, decimals: number } }
|
|
192
|
+
{
|
|
193
|
+
return type instanceof DataTypes.REAL;
|
|
194
|
+
}
|
|
195
|
+
protected isChar(type: any): type is { _length: number, options: { length: number } }
|
|
196
|
+
{
|
|
197
|
+
return type instanceof DataTypes.CHAR;
|
|
198
|
+
}
|
|
199
|
+
protected isString(type: any): type is { _length: number, options: { length: number } }
|
|
200
|
+
{
|
|
201
|
+
return type instanceof DataTypes.STRING;
|
|
202
|
+
}
|
|
203
|
+
protected isEnum(type: any): type is { options: { values: string[] } }
|
|
204
|
+
{
|
|
205
|
+
return type instanceof DataTypes.ENUM;
|
|
206
|
+
}
|
|
207
|
+
define(modelName: string, attributes: BaseSequelizeModelAttributes<M, Attributes<M>>, options?: ModelOptions<M>): void
|
|
208
|
+
{
|
|
209
|
+
this.database.addTable(modelName, this);
|
|
210
|
+
this.attributes = attributes;
|
|
211
|
+
if (!options)
|
|
212
|
+
options = {};
|
|
213
|
+
if (options.name == undefined)
|
|
214
|
+
options.name = {
|
|
215
|
+
plural: modelName,
|
|
216
|
+
singular: modelName
|
|
217
|
+
};
|
|
218
|
+
if (options.paranoid == undefined)
|
|
219
|
+
options.paranoid = true;
|
|
220
|
+
if (options.freezeTableName == undefined)
|
|
221
|
+
options.freezeTableName = true;
|
|
222
|
+
if (options.tableName == undefined)
|
|
223
|
+
options.tableName = modelName;
|
|
224
|
+
if (options.underscored == undefined)
|
|
225
|
+
options.underscored = true;
|
|
226
|
+
if (options.timestamps == undefined)
|
|
227
|
+
options.timestamps = true;
|
|
228
|
+
if (options.paranoid == undefined)
|
|
229
|
+
options.paranoid = true;
|
|
230
|
+
if (options.createdAt == undefined)
|
|
231
|
+
options.createdAt = 'created_at';
|
|
232
|
+
if (options.updatedAt == undefined)
|
|
233
|
+
options.updatedAt = 'updated_at';
|
|
234
|
+
if (options.deletedAt == undefined)
|
|
235
|
+
options.deletedAt = 'deleted_at';
|
|
236
|
+
|
|
237
|
+
this.model = this.database.sequelize.define(modelName, attributes, options);
|
|
238
|
+
}
|
|
239
|
+
public addForeignKey(primary: BaseSequelizeTable<BaseSequelizeDatabase, BaseSequelizeModel>, name: string, allowNull?: boolean)
|
|
240
|
+
{
|
|
241
|
+
let schema = this.getSchema(true);
|
|
242
|
+
let field = schema.fields?.find(x => x.name == name);
|
|
243
|
+
if (field == null)
|
|
244
|
+
throw new Error(`Column ${name} could not be found for relation between tables ${primary.getName()} and ${this.getName()}`);
|
|
245
|
+
|
|
246
|
+
primary.model.hasMany(this.model, { foreignKey: { name, allowNull }, sourceKey: "id" });
|
|
247
|
+
this.model.belongsTo(primary.model, { foreignKey: { name, allowNull }, targetKey: "id" });
|
|
248
|
+
}
|
|
249
|
+
async _getOrNull(options: FindOptions<Attributes<M>>, trx: Transaction | null): Promise<M | null>
|
|
250
|
+
{
|
|
251
|
+
options.transaction = trx;
|
|
252
|
+
return await this.model.findOne<M>(options);
|
|
253
|
+
}
|
|
254
|
+
async _get(options: FindOptions<Attributes<M>>, trx: Transaction | null): Promise<M>
|
|
255
|
+
{
|
|
256
|
+
let value = await this._getOrNull(options, trx);
|
|
257
|
+
if (value != null)
|
|
258
|
+
return value;
|
|
259
|
+
throw this.getNotFoundError(options.where);
|
|
260
|
+
}
|
|
261
|
+
async _list(where: WhereOptions<Attributes<M>>, pagination: { dont: true } | { page: number, size: number }, sorts: { dont: true } | SortItem[], options: FindOptions<Attributes<M>>, trx: Transaction | null): Promise<{ rows: M[], count: number }>
|
|
262
|
+
{
|
|
263
|
+
if (!('dont' in pagination))
|
|
264
|
+
{
|
|
265
|
+
let p = this.database.paginate(pagination.page, pagination.size);
|
|
266
|
+
options.offset = p.offset;
|
|
267
|
+
options.limit = p.limit;
|
|
268
|
+
}
|
|
269
|
+
if (!('dont' in sorts))
|
|
270
|
+
options.order = this.database.getSortOptions(sorts);
|
|
271
|
+
return await this.model.findAndCountAll({ ...options, where, distinct: true, subQuery: false, transaction: trx });
|
|
272
|
+
}
|
|
275
273
|
}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { BaseSequelizeDatabase } from "./BaseSequelizeDatabase";
|
|
2
|
-
|
|
3
|
-
export abstract class BaseSnowFlakeDatabase extends BaseSequelizeDatabase
|
|
4
|
-
{
|
|
5
|
-
constructor(host: string, port: number, name: string, user: string, pass: string, logging: boolean = false)
|
|
6
|
-
{
|
|
7
|
-
super('snowflake', host, port, name, user, pass, logging);
|
|
8
|
-
}
|
|
9
|
-
override getType()
|
|
10
|
-
{
|
|
11
|
-
return "SnowFlake";
|
|
12
|
-
}
|
|
1
|
+
import { BaseSequelizeDatabase } from "./BaseSequelizeDatabase";
|
|
2
|
+
|
|
3
|
+
export abstract class BaseSnowFlakeDatabase extends BaseSequelizeDatabase
|
|
4
|
+
{
|
|
5
|
+
constructor(host: string, port: number, name: string, user: string, pass: string, logging: boolean = false)
|
|
6
|
+
{
|
|
7
|
+
super('snowflake', host, port, name, user, pass, logging);
|
|
8
|
+
}
|
|
9
|
+
override getType()
|
|
10
|
+
{
|
|
11
|
+
return "SnowFlake";
|
|
12
|
+
}
|
|
13
13
|
}
|
package/src/index.ts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
export * from "./BaseDB2Database";
|
|
2
|
-
export * from "./BaseFilterItemBuilderSequelize";
|
|
3
|
-
export * from "./BaseMariaDBDatabase";
|
|
4
|
-
export * from "./BaseMSSQLDatabase";
|
|
5
|
-
export * from "./BaseMySqlDatabase";
|
|
6
|
-
export * from "./BaseOracleDatabase";
|
|
7
|
-
export * from "./BasePostgreSQLDatabase";
|
|
8
|
-
export * from "./BaseSequelizeDatabase";
|
|
9
|
-
export * from "./BaseSequelizeModel";
|
|
10
|
-
export * from "./BaseSequelizeModelAttributeColumnOptions";
|
|
11
|
-
export * from "./BaseSequelizeModelAttributes";
|
|
12
|
-
export * from "./BaseSequelizeTable";
|
|
13
|
-
export * from "./BaseSnowFlakeDatabase";
|
|
1
|
+
export * from "./BaseDB2Database";
|
|
2
|
+
export * from "./BaseFilterItemBuilderSequelize";
|
|
3
|
+
export * from "./BaseMariaDBDatabase";
|
|
4
|
+
export * from "./BaseMSSQLDatabase";
|
|
5
|
+
export * from "./BaseMySqlDatabase";
|
|
6
|
+
export * from "./BaseOracleDatabase";
|
|
7
|
+
export * from "./BasePostgreSQLDatabase";
|
|
8
|
+
export * from "./BaseSequelizeDatabase";
|
|
9
|
+
export * from "./BaseSequelizeModel";
|
|
10
|
+
export * from "./BaseSequelizeModelAttributeColumnOptions";
|
|
11
|
+
export * from "./BaseSequelizeModelAttributes";
|
|
12
|
+
export * from "./BaseSequelizeTable";
|
|
13
|
+
export * from "./BaseSnowFlakeDatabase";
|
|
14
14
|
export * from "./BaseSQLiteDatabase";
|