tspace-mysql 1.1.2 → 1.1.3
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/cli/index.js +23 -24
- package/dist/cli/migrate/make.js +18 -41
- package/dist/cli/models/make.js +18 -18
- package/dist/cli/models/model.js +27 -2
- package/dist/cli/tables/make.js +10 -10
- package/dist/cli/tables/table.js +22 -2
- package/dist/lib/config/env.d.ts +6 -0
- package/dist/lib/config/env.js +16 -10
- package/dist/lib/connection/index.d.ts +29 -8
- package/dist/lib/connection/index.js +111 -55
- package/dist/lib/constants/index.js +7 -5
- package/dist/lib/index.d.ts +1 -1
- package/dist/lib/index.js +2 -2
- package/dist/lib/tspace/AbstractDB.js +3 -23
- package/dist/lib/tspace/AbstractDatabase.d.ts +9 -4
- package/dist/lib/tspace/AbstractDatabase.js +28 -31
- package/dist/lib/tspace/AbstractModel.d.ts +30 -16
- package/dist/lib/tspace/AbstractModel.js +3 -23
- package/dist/lib/tspace/Blueprint.d.ts +92 -21
- package/dist/lib/tspace/Blueprint.js +171 -140
- package/dist/lib/tspace/DB.d.ts +27 -4
- package/dist/lib/tspace/DB.js +66 -158
- package/dist/lib/tspace/Database.d.ts +100 -51
- package/dist/lib/tspace/Database.js +1335 -1911
- package/dist/lib/tspace/Interface.d.ts +8 -8
- package/dist/lib/tspace/Logger.js +19 -19
- package/dist/lib/tspace/Model.d.ts +168 -132
- package/dist/lib/tspace/Model.js +1467 -2081
- package/dist/lib/tspace/ProxyHandler.js +15 -26
- package/dist/lib/tspace/Schema.js +25 -117
- package/dist/lib/tspace/index.js +4 -4
- package/dist/lib/utils/index.d.ts +4 -3
- package/dist/lib/utils/index.js +87 -112
- package/package.json +1 -1
|
@@ -38,7 +38,7 @@ export interface Pagination {
|
|
|
38
38
|
}
|
|
39
39
|
export interface Backup {
|
|
40
40
|
database: string;
|
|
41
|
-
|
|
41
|
+
to?: {
|
|
42
42
|
host: string;
|
|
43
43
|
port: number;
|
|
44
44
|
database: string;
|
|
@@ -68,12 +68,12 @@ export interface ConnectionOptions {
|
|
|
68
68
|
username: string;
|
|
69
69
|
password: string;
|
|
70
70
|
}
|
|
71
|
-
export interface
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
71
|
+
export interface Execute {
|
|
72
|
+
sql: string;
|
|
73
|
+
type: string;
|
|
74
|
+
message?: string;
|
|
75
|
+
options?: {
|
|
76
|
+
[key: string]: any;
|
|
77
|
+
};
|
|
78
78
|
}
|
|
79
79
|
export declare type Pattern = 'snake_case' | 'camelCase';
|
|
@@ -1,48 +1,48 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Logger = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
class Logger {
|
|
5
|
+
SELF;
|
|
6
|
+
PROP = '';
|
|
7
|
+
constructor(self, prop) {
|
|
7
8
|
this.SELF = self;
|
|
8
9
|
this.PROP = prop;
|
|
9
10
|
return this.initialize();
|
|
10
11
|
}
|
|
11
|
-
|
|
12
|
-
var _a;
|
|
12
|
+
initialize() {
|
|
13
13
|
if (this.SELF == null)
|
|
14
14
|
return;
|
|
15
|
-
|
|
15
|
+
const runing = this.SELF[this.PROP];
|
|
16
16
|
if (runing == null)
|
|
17
17
|
return;
|
|
18
|
-
|
|
18
|
+
const _function = typeof runing;
|
|
19
19
|
if (_function !== 'function')
|
|
20
20
|
return;
|
|
21
21
|
if (this.SELF.$logger == null)
|
|
22
22
|
return;
|
|
23
|
-
|
|
23
|
+
const ignores = [
|
|
24
24
|
'table',
|
|
25
25
|
'hasOne',
|
|
26
26
|
'belongsTo',
|
|
27
27
|
'hasMany',
|
|
28
28
|
'belongsToMany',
|
|
29
|
-
'constructor'
|
|
29
|
+
'constructor',
|
|
30
|
+
'boot'
|
|
30
31
|
];
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
32
|
+
const _use = this.PROP.substring(0, 3) !== 'use';
|
|
33
|
+
const _private = this.PROP.charAt(0) !== '_';
|
|
34
|
+
const _setter = this.PROP.charAt(0) !== '$';
|
|
35
|
+
const _ignore = ignores.indexOf(this.PROP) === -1;
|
|
36
|
+
const conditions = [
|
|
36
37
|
_use,
|
|
37
38
|
_private,
|
|
38
39
|
_ignore,
|
|
39
40
|
_setter
|
|
40
|
-
].every(
|
|
41
|
+
].every((data) => data === true);
|
|
41
42
|
if (!conditions)
|
|
42
43
|
return;
|
|
43
|
-
return
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
}());
|
|
44
|
+
return this.SELF.$logger?.set(this.PROP);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
47
|
exports.Logger = Logger;
|
|
48
48
|
exports.default = Logger;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { AbstractModel } from './AbstractModel';
|
|
2
|
-
import { Relation, Pagination,
|
|
2
|
+
import { Relation, Pagination, RelationQuery } from './Interface';
|
|
3
3
|
declare class Model extends AbstractModel {
|
|
4
|
-
[
|
|
4
|
+
[x: string]: any;
|
|
5
5
|
constructor();
|
|
6
6
|
/**
|
|
7
7
|
*
|
|
@@ -17,10 +17,10 @@ declare class Model extends AbstractModel {
|
|
|
17
17
|
usePrimaryKey(primary: string): this;
|
|
18
18
|
/**
|
|
19
19
|
* Assign in model uuid when creating
|
|
20
|
-
* @param {string} uuid custom column
|
|
20
|
+
* @param {string?} column [column=uuid] custom column replace this
|
|
21
21
|
* @return {this} this
|
|
22
22
|
*/
|
|
23
|
-
useUUID(
|
|
23
|
+
useUUID(column?: string): this;
|
|
24
24
|
/**
|
|
25
25
|
* Assign in model console.log sql statement
|
|
26
26
|
* @return {this} this
|
|
@@ -37,18 +37,16 @@ declare class Model extends AbstractModel {
|
|
|
37
37
|
*
|
|
38
38
|
* Assign in model show data not be deleted
|
|
39
39
|
* Relations has reference this method
|
|
40
|
+
* @param {string?} column
|
|
40
41
|
* @return {this} this
|
|
41
42
|
*/
|
|
42
|
-
useSoftDelete(): this;
|
|
43
|
-
/**
|
|
44
|
-
* Assign in model show data not be deleted in relations
|
|
45
|
-
* repicate
|
|
46
|
-
* @return {this} this
|
|
47
|
-
*/
|
|
48
|
-
useDisableSoftDeleteInRelations(): this;
|
|
43
|
+
useSoftDelete(column?: string): this;
|
|
49
44
|
/**
|
|
50
45
|
*
|
|
51
46
|
* Assign timestamp when insert || updated created_at and update_at in table
|
|
47
|
+
* @param {object} timestampFormat
|
|
48
|
+
* @property {string} timestampFormat.createdAt - change column of created at
|
|
49
|
+
* @property {string} timestampFormat.updatedAt - change column of updated at
|
|
52
50
|
* @return {this} this
|
|
53
51
|
*/
|
|
54
52
|
useTimestamp(timestampFormat?: {
|
|
@@ -58,6 +56,7 @@ declare class Model extends AbstractModel {
|
|
|
58
56
|
/**
|
|
59
57
|
*
|
|
60
58
|
* Assign table name in model
|
|
59
|
+
* @param {string} table table name in database
|
|
61
60
|
* @return {this} this
|
|
62
61
|
*/
|
|
63
62
|
useTable(table: string): this;
|
|
@@ -73,19 +72,34 @@ declare class Model extends AbstractModel {
|
|
|
73
72
|
* @return {this} this
|
|
74
73
|
*/
|
|
75
74
|
useTablePlural(): this;
|
|
75
|
+
/**
|
|
76
|
+
*
|
|
77
|
+
* boot for initialize of models
|
|
78
|
+
* @return {this} this
|
|
79
|
+
*/
|
|
80
|
+
boot(): this;
|
|
81
|
+
/**
|
|
82
|
+
*
|
|
83
|
+
* Clone instance of model
|
|
84
|
+
* @override Method
|
|
85
|
+
* @return {this} this
|
|
86
|
+
*/
|
|
87
|
+
clone(instance: Model): this;
|
|
76
88
|
/**
|
|
77
89
|
* Assign ignore delete_at in model
|
|
90
|
+
* @param {boolean} condition
|
|
78
91
|
* @return {this} this
|
|
79
92
|
*/
|
|
80
93
|
ignoreSoftDelete(condition?: boolean): this;
|
|
81
94
|
/**
|
|
82
|
-
*
|
|
95
|
+
* Assign ignore delete_at in model
|
|
96
|
+
* @param {boolean} condition
|
|
83
97
|
* @return {this} this
|
|
84
98
|
*/
|
|
85
99
|
disableSoftDelete(condition?: boolean): this;
|
|
86
100
|
/**
|
|
87
|
-
*
|
|
88
|
-
* @param {
|
|
101
|
+
* Assign build in function to result of data
|
|
102
|
+
* @param {object} func
|
|
89
103
|
* @return {this} this
|
|
90
104
|
*/
|
|
91
105
|
registry(func: {
|
|
@@ -93,120 +107,146 @@ declare class Model extends AbstractModel {
|
|
|
93
107
|
}): this;
|
|
94
108
|
/**
|
|
95
109
|
*
|
|
96
|
-
*
|
|
110
|
+
* Use relations in registry of model return result of relation query
|
|
97
111
|
* @param {...string} nameRelations ...name registry in models using (hasOne , hasMany , belongsTo , belongsToMany)
|
|
98
112
|
* @return {this} this
|
|
99
113
|
*/
|
|
100
114
|
with(...nameRelations: Array<string>): this;
|
|
101
115
|
/**
|
|
102
116
|
*
|
|
103
|
-
*
|
|
117
|
+
* Use relations in registry of model return only exists result of relation query
|
|
104
118
|
* @param {...string} nameRelations if data exists return blank
|
|
105
|
-
* @return {this}
|
|
119
|
+
* @return {this} this
|
|
106
120
|
*/
|
|
107
121
|
withExists(...nameRelations: Array<string>): this;
|
|
108
122
|
/**
|
|
109
123
|
*
|
|
110
|
-
*
|
|
124
|
+
* Use relation '${name}' registry of model return callback this query model
|
|
111
125
|
* @param {string} nameRelation name relation in registry in your model
|
|
112
126
|
* @param {function} callback query callback
|
|
113
127
|
* @return {this} this
|
|
114
128
|
*/
|
|
115
129
|
withQuery(nameRelation: string, callback: Function): this;
|
|
116
130
|
/**
|
|
117
|
-
*
|
|
118
|
-
*
|
|
119
|
-
* @param {string}
|
|
120
|
-
* @param {string} relation.as
|
|
121
|
-
* @param {class} relation.model
|
|
122
|
-
* @param {string} relation.localKey
|
|
123
|
-
* @param {string} relation.foreignKey
|
|
124
|
-
* @param {string} relation.freezeTable
|
|
131
|
+
*
|
|
132
|
+
* Use relations in registry of model retrun result of relation query
|
|
133
|
+
* @param {...string} nameRelations ...name registry in models using (hasOne , hasMany , belongsTo , belongsToMany)
|
|
125
134
|
* @return {this} this
|
|
126
135
|
*/
|
|
136
|
+
relations(...nameRelations: Array<string>): this;
|
|
137
|
+
/**
|
|
138
|
+
*
|
|
139
|
+
* Use relations in registry of model return only exists result of relation query
|
|
140
|
+
* @param {...string} nameRelations if data exists return blank
|
|
141
|
+
* @return {this}
|
|
142
|
+
*/
|
|
143
|
+
relationsExists(...nameRelations: Array<string>): this;
|
|
144
|
+
/**
|
|
145
|
+
*
|
|
146
|
+
* Use relation '${name}' registry of model return callback this query model
|
|
147
|
+
* @param {string} nameRelation name relation in registry in your model
|
|
148
|
+
* @param {function} callback query callback
|
|
149
|
+
* @return {this} this
|
|
150
|
+
*/
|
|
151
|
+
relationQuery(nameRelation: string, callback: Function): this;
|
|
152
|
+
/**
|
|
153
|
+
* Assign the relation in model Objects
|
|
154
|
+
* @param {object} relations registry relation in your model
|
|
155
|
+
* @property {string} relation.name
|
|
156
|
+
* @property {string} relation.as
|
|
157
|
+
* @property {class} relation.model
|
|
158
|
+
* @property {string} relation.localKey
|
|
159
|
+
* @property {string} relation.foreignKey
|
|
160
|
+
* @property {string} relation.freezeTable
|
|
161
|
+
* @return {this} this
|
|
162
|
+
*/
|
|
127
163
|
hasOne({ name, as, model, localKey, foreignKey, freezeTable }: Relation): this;
|
|
128
164
|
/**
|
|
129
165
|
* Assign the relation in model Objects
|
|
130
|
-
* @param
|
|
131
|
-
* @
|
|
132
|
-
* @
|
|
133
|
-
* @
|
|
134
|
-
* @
|
|
135
|
-
* @
|
|
136
|
-
* @
|
|
137
|
-
* @return
|
|
166
|
+
* @param {object} relations registry relation in your model
|
|
167
|
+
* @property {string} relation.name
|
|
168
|
+
* @property {string} relation.as
|
|
169
|
+
* @property {class} relation.model
|
|
170
|
+
* @property {string} relation.localKey
|
|
171
|
+
* @property {string} relation.foreignKey
|
|
172
|
+
* @property {string} relation.freezeTable
|
|
173
|
+
* @return {this} this
|
|
138
174
|
*/
|
|
139
175
|
hasMany({ name, as, model, localKey, foreignKey, freezeTable }: Relation): this;
|
|
140
176
|
/**
|
|
141
177
|
* Assign the relation in model Objects
|
|
142
|
-
* @param
|
|
143
|
-
* @
|
|
144
|
-
* @
|
|
145
|
-
* @
|
|
146
|
-
* @
|
|
147
|
-
* @
|
|
148
|
-
* @
|
|
149
|
-
* @return
|
|
178
|
+
* @param {object} relations registry relation in your model
|
|
179
|
+
* @property {string} relation.name
|
|
180
|
+
* @property {string} relation.as
|
|
181
|
+
* @property {class} relation.model
|
|
182
|
+
* @property {string} relation.localKey
|
|
183
|
+
* @property {string} relation.foreignKey
|
|
184
|
+
* @property {string} relation.freezeTable
|
|
185
|
+
* @return {this} this
|
|
150
186
|
*/
|
|
151
187
|
belongsTo({ name, as, model, localKey, foreignKey, freezeTable }: Relation): this;
|
|
152
188
|
/**
|
|
153
189
|
* Assign the relation in model Objects
|
|
154
|
-
* @param
|
|
155
|
-
* @
|
|
156
|
-
* @
|
|
157
|
-
* @
|
|
158
|
-
* @
|
|
159
|
-
* @
|
|
160
|
-
* @
|
|
161
|
-
* @return
|
|
190
|
+
* @param {object} relations registry relation in your model
|
|
191
|
+
* @property {string} relation.name
|
|
192
|
+
* @property {string} relation.as
|
|
193
|
+
* @property {class} relation.model
|
|
194
|
+
* @property {string} relation.localKey
|
|
195
|
+
* @property {string} relation.foreignKey
|
|
196
|
+
* @property {string} relation.freezeTable
|
|
197
|
+
* @return {this} this
|
|
162
198
|
*/
|
|
163
199
|
belongsToMany({ name, as, model, localKey, foreignKey, freezeTable }: Relation): this;
|
|
164
200
|
/**
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
201
|
+
* Assign the relation in model Objects
|
|
202
|
+
* @param {object} relations registry relation in your model
|
|
203
|
+
* @property {string} relation.name
|
|
204
|
+
* @property {string} relation.as
|
|
205
|
+
* @property {class} relation.model
|
|
206
|
+
* @property {string} relation.localKey
|
|
207
|
+
* @property {string} relation.foreignKey
|
|
208
|
+
* @property {string} relation.freezeTable
|
|
209
|
+
* @param {function} callback callback query relation of model
|
|
210
|
+
* @return {this} this
|
|
211
|
+
*/
|
|
175
212
|
hasOneQuery({ name, as, model, localKey, foreignKey, freezeTable }: RelationQuery, callback: Function): this;
|
|
176
213
|
/**
|
|
177
214
|
* Assign the relation in model Objects
|
|
178
|
-
* @param
|
|
179
|
-
* @
|
|
180
|
-
* @
|
|
181
|
-
* @
|
|
182
|
-
* @
|
|
183
|
-
* @
|
|
184
|
-
* @
|
|
185
|
-
* @
|
|
215
|
+
* @param {object} relations registry relation in your model
|
|
216
|
+
* @property {string} relation.name
|
|
217
|
+
* @property {string} relation.as
|
|
218
|
+
* @property {class} relation.model
|
|
219
|
+
* @property {string} relation.localKey
|
|
220
|
+
* @property {string} relation.foreignKey
|
|
221
|
+
* @property {string} relation.freezeTable
|
|
222
|
+
* @param {function} callback callback query relation of model
|
|
223
|
+
* @return {this} this
|
|
186
224
|
*/
|
|
187
225
|
hasManyQuery({ name, as, model, localKey, foreignKey, freezeTable }: RelationQuery, callback: Function): this;
|
|
188
226
|
/**
|
|
189
227
|
* Assign the relation in model Objects
|
|
190
|
-
* @param
|
|
191
|
-
* @
|
|
192
|
-
* @
|
|
193
|
-
* @
|
|
194
|
-
* @
|
|
195
|
-
* @
|
|
196
|
-
* @
|
|
197
|
-
* @
|
|
228
|
+
* @param {object} relations registry relation in your model
|
|
229
|
+
* @property {string} relation.name
|
|
230
|
+
* @property {string} relation.as
|
|
231
|
+
* @property {class} relation.model
|
|
232
|
+
* @property {string} relation.localKey
|
|
233
|
+
* @property {string} relation.foreignKey
|
|
234
|
+
* @property {string} relation.freezeTable
|
|
235
|
+
* @param {function} callback callback query relation of model
|
|
236
|
+
* @return {this} this
|
|
198
237
|
*/
|
|
199
238
|
belongsToQuery({ name, as, model, localKey, foreignKey, freezeTable }: RelationQuery, callback: Function): this;
|
|
200
239
|
/**
|
|
201
240
|
* Assign the relation in model Objects
|
|
202
|
-
* @param
|
|
203
|
-
* @
|
|
204
|
-
* @
|
|
205
|
-
* @
|
|
206
|
-
* @
|
|
207
|
-
* @
|
|
208
|
-
* @
|
|
209
|
-
* @
|
|
241
|
+
* @param {object} relations registry relation in your model
|
|
242
|
+
* @property {string} relation.name
|
|
243
|
+
* @property {string} relation.as
|
|
244
|
+
* @property {class} relation.model
|
|
245
|
+
* @property {string} relation.localKey
|
|
246
|
+
* @property {string} relation.foreignKey
|
|
247
|
+
* @property {string} relation.freezeTable
|
|
248
|
+
* @param {function} callback callback query relation of model
|
|
249
|
+
* @return {this} this
|
|
210
250
|
*/
|
|
211
251
|
belongsToManyQuery({ name, as, model, localKey, foreignKey, freezeTable }: RelationQuery, callback: Function): this;
|
|
212
252
|
/**
|
|
@@ -259,7 +299,7 @@ declare class Model extends AbstractModel {
|
|
|
259
299
|
/**
|
|
260
300
|
*
|
|
261
301
|
* @override Method
|
|
262
|
-
* @param {string
|
|
302
|
+
* @param {string} column [column=id]
|
|
263
303
|
* @return {promise<number>}
|
|
264
304
|
*/
|
|
265
305
|
sum(column?: string): Promise<number>;
|
|
@@ -293,7 +333,7 @@ declare class Model extends AbstractModel {
|
|
|
293
333
|
/**
|
|
294
334
|
*
|
|
295
335
|
* @override Method
|
|
296
|
-
* @return {promise<
|
|
336
|
+
* @return {promise<any>}
|
|
297
337
|
*/
|
|
298
338
|
first(): Promise<{
|
|
299
339
|
[key: string]: any;
|
|
@@ -301,11 +341,29 @@ declare class Model extends AbstractModel {
|
|
|
301
341
|
/**
|
|
302
342
|
*
|
|
303
343
|
* @override Method
|
|
304
|
-
* @return {promise<
|
|
344
|
+
* @return {promise<any>}
|
|
305
345
|
*/
|
|
306
|
-
findOne(): Promise<
|
|
346
|
+
findOne(): Promise<any>;
|
|
347
|
+
/**
|
|
348
|
+
*
|
|
349
|
+
* @override Method
|
|
350
|
+
* @return {promise<object | Error>}
|
|
351
|
+
*/
|
|
352
|
+
firstOrError(message: string, options?: {
|
|
307
353
|
[key: string]: any;
|
|
308
|
-
}
|
|
354
|
+
}): Promise<{
|
|
355
|
+
[key: string]: any;
|
|
356
|
+
}>;
|
|
357
|
+
/**
|
|
358
|
+
*
|
|
359
|
+
* @override Method
|
|
360
|
+
* @return {promise<any>}
|
|
361
|
+
*/
|
|
362
|
+
findOneOrError(message: string, options?: {
|
|
363
|
+
[key: string]: any;
|
|
364
|
+
}): Promise<{
|
|
365
|
+
[key: string]: any;
|
|
366
|
+
}>;
|
|
309
367
|
/**
|
|
310
368
|
*
|
|
311
369
|
* @override Method
|
|
@@ -317,9 +375,7 @@ declare class Model extends AbstractModel {
|
|
|
317
375
|
* @override Method
|
|
318
376
|
* @return {promise<object | null>}
|
|
319
377
|
*/
|
|
320
|
-
find(id: number): Promise<
|
|
321
|
-
[key: string]: any;
|
|
322
|
-
} | null>;
|
|
378
|
+
find(id: number): Promise<any>;
|
|
323
379
|
/**
|
|
324
380
|
*
|
|
325
381
|
* @override Method
|
|
@@ -335,9 +391,9 @@ declare class Model extends AbstractModel {
|
|
|
335
391
|
/**
|
|
336
392
|
*
|
|
337
393
|
* @override Method
|
|
338
|
-
* @param {?object} paginationOptions
|
|
339
|
-
* @
|
|
340
|
-
* @
|
|
394
|
+
* @param {?object} paginationOptions by default page = 1 , limit = 15
|
|
395
|
+
* @property {number} paginationOptions.limit
|
|
396
|
+
* @property {number} paginationOptions.page
|
|
341
397
|
* @return {promise<Pagination>}
|
|
342
398
|
*/
|
|
343
399
|
pagination(paginationOptions?: {
|
|
@@ -345,13 +401,13 @@ declare class Model extends AbstractModel {
|
|
|
345
401
|
page?: number;
|
|
346
402
|
}): Promise<Pagination>;
|
|
347
403
|
/**
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
404
|
+
*
|
|
405
|
+
* @override Method
|
|
406
|
+
* @param {?object} paginationOptions by default page = 1 , limit = 15
|
|
407
|
+
* @property {number} paginationOptions.limit
|
|
408
|
+
* @property {number} paginationOptions.page
|
|
409
|
+
* @return {promise<Pagination>}
|
|
410
|
+
*/
|
|
355
411
|
paginate(paginationOptions?: {
|
|
356
412
|
limit?: number;
|
|
357
413
|
page?: number;
|
|
@@ -415,7 +471,7 @@ declare class Model extends AbstractModel {
|
|
|
415
471
|
createOrUpdate(data: object): this;
|
|
416
472
|
/**
|
|
417
473
|
*
|
|
418
|
-
* insert
|
|
474
|
+
* insert multiple data into the database
|
|
419
475
|
* @override Method
|
|
420
476
|
* @param {array<object>} data create multiple data
|
|
421
477
|
* @return {this} this this
|
|
@@ -432,39 +488,16 @@ declare class Model extends AbstractModel {
|
|
|
432
488
|
/**
|
|
433
489
|
*
|
|
434
490
|
* @override Method
|
|
435
|
-
* @
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
*
|
|
439
|
-
* try {
|
|
440
|
-
* const useSave = await create ...something then .save(transaction)
|
|
441
|
-
* const useSave2 = await create ...something then .save(transaction)
|
|
442
|
-
* throw new Error('try to errors')
|
|
443
|
-
* } catch (e) {
|
|
444
|
-
* const rollback = await transaction.rollback()
|
|
445
|
-
* // rollback => ture
|
|
446
|
-
* // !done transaction has been rolled back [useSave , useSave2]
|
|
447
|
-
* }
|
|
448
|
-
*
|
|
449
|
-
* @return {Promise<array | object | null>}
|
|
450
|
-
*/
|
|
451
|
-
save(transaction?: Transaction): Promise<Array<any> | {
|
|
452
|
-
[key: string]: any;
|
|
453
|
-
} | null>;
|
|
491
|
+
* @return {Promise<any>}
|
|
492
|
+
*/
|
|
493
|
+
save(): Promise<any>;
|
|
454
494
|
/**
|
|
455
495
|
*
|
|
456
496
|
* fake data
|
|
457
497
|
* @param {number} rows number of rows
|
|
458
|
-
* @return {promise<any}
|
|
498
|
+
* @return {promise<any>}
|
|
459
499
|
*/
|
|
460
500
|
faker(rows?: number): Promise<any>;
|
|
461
|
-
/**
|
|
462
|
-
*
|
|
463
|
-
* @override Method
|
|
464
|
-
* @param {number} id
|
|
465
|
-
* @return {this}
|
|
466
|
-
*/
|
|
467
|
-
whereUser(id: number): this;
|
|
468
501
|
private _queryStatementModel;
|
|
469
502
|
private _actionStatementModel;
|
|
470
503
|
private _valuePattern;
|
|
@@ -472,12 +505,14 @@ declare class Model extends AbstractModel {
|
|
|
472
505
|
private _classToTableName;
|
|
473
506
|
private _tableName;
|
|
474
507
|
private _valueInRelation;
|
|
475
|
-
private
|
|
508
|
+
private _buildQueryModel;
|
|
476
509
|
private _exceptColumns;
|
|
477
510
|
private _showOnly;
|
|
478
511
|
private _execute;
|
|
479
512
|
private _executeGroup;
|
|
480
|
-
private
|
|
513
|
+
private _relationMapData;
|
|
514
|
+
private _handleRelationsExists;
|
|
515
|
+
private _queryRelationsExists;
|
|
481
516
|
private _relation;
|
|
482
517
|
private _handleBelongsToMany;
|
|
483
518
|
private _belongsToMany;
|
|
@@ -499,6 +534,7 @@ declare class Model extends AbstractModel {
|
|
|
499
534
|
private _updateModel;
|
|
500
535
|
private _assertError;
|
|
501
536
|
private _functionRelationName;
|
|
537
|
+
private _handleRelationsQuery;
|
|
502
538
|
private _initialModel;
|
|
503
539
|
private _setupModel;
|
|
504
540
|
}
|