tspace-mysql 1.4.6 → 1.4.7
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 +161 -69
- package/dist/cli/generate/model.js +1 -1
- package/dist/lib/connection/index.d.ts +1 -1
- package/dist/lib/connection/index.js +1 -1
- package/dist/lib/constants/index.js +12 -10
- package/dist/lib/tspace/Abstract/AbstractBuilder.d.ts +4 -2
- package/dist/lib/tspace/Abstract/AbstractBuilder.js +5 -1
- package/dist/lib/tspace/Abstract/AbstractDB.d.ts +0 -2
- package/dist/lib/tspace/Abstract/AbstractModel.d.ts +6 -4
- package/dist/lib/tspace/Abstract/AbstractModel.js +2 -5
- package/dist/lib/tspace/Blueprint.d.ts +10 -2
- package/dist/lib/tspace/Blueprint.js +11 -1
- package/dist/lib/tspace/Builder.d.ts +556 -189
- package/dist/lib/tspace/Builder.js +1400 -947
- package/dist/lib/tspace/DB.d.ts +100 -88
- package/dist/lib/tspace/DB.js +134 -212
- package/dist/lib/tspace/Interface.d.ts +24 -4
- package/dist/lib/tspace/Model.d.ts +312 -205
- package/dist/lib/tspace/Model.js +921 -1073
- package/dist/lib/tspace/RelationHandler.d.ts +32 -0
- package/dist/lib/tspace/RelationHandler.js +529 -0
- package/dist/lib/tspace/Schema.d.ts +9 -4
- package/dist/lib/tspace/Schema.js +119 -45
- package/dist/lib/tspace/StateHandler.js +4 -0
- package/dist/lib/utils/index.d.ts +4 -1
- package/dist/lib/utils/index.js +29 -3
- package/package.json +1 -1
|
@@ -1,10 +1,16 @@
|
|
|
1
1
|
import { AbstractModel } from './Abstract/AbstractModel';
|
|
2
|
-
import { Relation, Pagination, RelationQuery } from './Interface';
|
|
2
|
+
import { Relation, Pagination, RelationQuery, ValidateSchema } from './Interface';
|
|
3
|
+
/**
|
|
4
|
+
*
|
|
5
|
+
* 'Model' class is a representation of a database table
|
|
6
|
+
* @example
|
|
7
|
+
* class User extends Model {}
|
|
8
|
+
* new User().findMany().then(users => console.log(users))
|
|
9
|
+
*/
|
|
3
10
|
declare class Model extends AbstractModel {
|
|
4
11
|
constructor();
|
|
5
12
|
/**
|
|
6
|
-
*
|
|
7
|
-
* define for initialize of models
|
|
13
|
+
* The 'define' method is a special method that you can define within a model.
|
|
8
14
|
* @example
|
|
9
15
|
* class User extends Model {
|
|
10
16
|
* define() {
|
|
@@ -18,8 +24,7 @@ declare class Model extends AbstractModel {
|
|
|
18
24
|
*/
|
|
19
25
|
protected define(): void;
|
|
20
26
|
/**
|
|
21
|
-
*
|
|
22
|
-
* boot for initialize of models like constructor()
|
|
27
|
+
* The 'boot' method is a special method that you can define within a model.
|
|
23
28
|
* @example
|
|
24
29
|
* class User extends Model {
|
|
25
30
|
* boot() {
|
|
@@ -33,8 +38,43 @@ declare class Model extends AbstractModel {
|
|
|
33
38
|
*/
|
|
34
39
|
protected boot(): void;
|
|
35
40
|
/**
|
|
41
|
+
* The "useObserve" pattern refers to a way of handling model events using observer classes.
|
|
42
|
+
* Model events are triggered when certain actions occur on models,
|
|
43
|
+
* such as creating, updating, deleting, or saving a record.
|
|
44
|
+
*
|
|
45
|
+
* Observers are used to encapsulate the event-handling logic for these events,
|
|
46
|
+
* keeping the logic separate from the model itself and promoting cleaner, more maintainable code.
|
|
47
|
+
* @param {Function} observer
|
|
48
|
+
* @return this
|
|
49
|
+
* @example
|
|
50
|
+
*
|
|
51
|
+
* class UserObserve {
|
|
52
|
+
*
|
|
53
|
+
* public created(results : unknown) {
|
|
54
|
+
* console.log({ results , created : true })
|
|
55
|
+
* }
|
|
56
|
+
*
|
|
57
|
+
* public updated(results : unknown) {
|
|
58
|
+
* console.log({ results ,updated : true })
|
|
59
|
+
* }
|
|
60
|
+
*
|
|
61
|
+
* public deleted(results : unknown) {
|
|
62
|
+
* console.log({ results ,deleted : true })
|
|
63
|
+
* }
|
|
64
|
+
* }
|
|
65
|
+
*
|
|
66
|
+
* class User extends Model {
|
|
67
|
+
* constructor() {
|
|
68
|
+
* super()
|
|
69
|
+
* this.useObserver(UserObserve)
|
|
70
|
+
* }
|
|
71
|
+
* }
|
|
72
|
+
*/
|
|
73
|
+
protected useObserver(observer: Function): this;
|
|
74
|
+
/**
|
|
75
|
+
* The "useSchema" method is used to define the schema.
|
|
36
76
|
*
|
|
37
|
-
*
|
|
77
|
+
* It's automatically create, called when not exists table or columns.
|
|
38
78
|
* @param {object} schema using Blueprint for schema
|
|
39
79
|
* @example
|
|
40
80
|
* import { Blueprint } from 'tspace-mysql'
|
|
@@ -55,103 +95,113 @@ declare class Model extends AbstractModel {
|
|
|
55
95
|
protected useSchema(schema: Record<string, any>): this;
|
|
56
96
|
/**
|
|
57
97
|
*
|
|
58
|
-
*
|
|
98
|
+
* The "useRegistry" method is used to define Function to results.
|
|
99
|
+
*
|
|
100
|
+
* It's automatically given Function to results.
|
|
101
|
+
* @return {this} this
|
|
59
102
|
* @example
|
|
60
103
|
* class User extends Model {
|
|
61
104
|
* constructor() {
|
|
62
105
|
* this.useRegistry()
|
|
63
106
|
* }
|
|
64
107
|
* }
|
|
65
|
-
|
|
108
|
+
|
|
66
109
|
*/
|
|
67
110
|
protected useRegistry(): this;
|
|
68
111
|
/**
|
|
69
|
-
*
|
|
70
|
-
*
|
|
112
|
+
* The "useLoadRelationsInRegistry" method is used automatically called relations in your registry Model.
|
|
113
|
+
* @return {this} this
|
|
71
114
|
* @example
|
|
72
115
|
* class User extends Model {
|
|
73
116
|
* constructor() {
|
|
74
117
|
* this.useLoadRelationInRegistry()
|
|
75
118
|
* }
|
|
76
119
|
* }
|
|
77
|
-
* @return {this} this
|
|
78
120
|
*/
|
|
79
121
|
protected useLoadRelationsInRegistry(): this;
|
|
80
122
|
/**
|
|
123
|
+
* The "useBuiltInRelationFunctions" method is used to define the function.
|
|
81
124
|
*
|
|
82
|
-
*
|
|
125
|
+
* It's automatically given built-in relation functions to a results.
|
|
126
|
+
* @return {this} this
|
|
83
127
|
* @example
|
|
84
128
|
* class User extends Model {
|
|
85
129
|
* constructor() {
|
|
86
130
|
* this.useBuiltInRelationsFunction()
|
|
87
131
|
* }
|
|
88
132
|
* }
|
|
89
|
-
* @return {this} this
|
|
90
133
|
*/
|
|
91
134
|
protected useBuiltInRelationFunctions(): this;
|
|
92
135
|
/**
|
|
136
|
+
* The "usePrimaryKey" method is add primary keys for database tables.
|
|
93
137
|
*
|
|
94
|
-
* Assign primary column in model
|
|
95
138
|
* @param {string} primary
|
|
139
|
+
* @return {this} this
|
|
96
140
|
* @example
|
|
97
141
|
* class User extends Model {
|
|
98
142
|
* constructor() {
|
|
99
143
|
* this.usePrimaryKey()
|
|
100
144
|
* }
|
|
101
145
|
* }
|
|
102
|
-
* @return {this} this
|
|
103
146
|
*/
|
|
104
147
|
protected usePrimaryKey(primary: string): this;
|
|
105
148
|
/**
|
|
106
|
-
*
|
|
149
|
+
* The "useUUID" method is a concept of using UUIDs (Universally Unique Identifiers) as column 'uuid' in table.
|
|
150
|
+
*
|
|
151
|
+
* It's automatically genarate when created a result.
|
|
107
152
|
* @param {string?} column [column=uuid] make new name column for custom column replace uuid with this
|
|
153
|
+
* @return {this} this
|
|
108
154
|
* @example
|
|
109
155
|
* class User extends Model {
|
|
110
156
|
* constructor() {
|
|
111
157
|
* this.useUUID()
|
|
112
158
|
* }
|
|
113
159
|
* }
|
|
114
|
-
* @return {this} this
|
|
115
160
|
*/
|
|
116
161
|
protected useUUID(column?: string): this;
|
|
117
162
|
/**
|
|
118
|
-
*
|
|
163
|
+
* The "useDebug" method is viewer raw-sql logs when excute the results.
|
|
119
164
|
* @return {this} this
|
|
120
165
|
*/
|
|
121
166
|
protected useDebug(): this;
|
|
122
167
|
/**
|
|
123
|
-
*
|
|
124
|
-
* Assign in model use pattern [snake_case , camelCase]
|
|
168
|
+
* The "usePattern" method is used to assign pattern [snake_case , camelCase].
|
|
125
169
|
* @param {string} pattern
|
|
170
|
+
* @return {this} this
|
|
126
171
|
* @example
|
|
127
172
|
* class User extends Model {
|
|
128
173
|
* constructor() {
|
|
129
174
|
* this.usePattern('camelCase')
|
|
130
175
|
* }
|
|
131
176
|
* }
|
|
132
|
-
* @return {this} this
|
|
133
177
|
*/
|
|
134
178
|
protected usePattern(pattern: "snake_case" | "camelCase"): this;
|
|
179
|
+
protected useCamelCase(): this;
|
|
180
|
+
protected useSnakeCase(): this;
|
|
135
181
|
/**
|
|
182
|
+
* The "useSoftDelete" refer to a feature that allows you to "soft delete" records from a database table instead of permanently deleting them.
|
|
136
183
|
*
|
|
137
|
-
*
|
|
138
|
-
*
|
|
184
|
+
* Soft deleting means that the records are not physically removed from the database but are instead marked as deleted by setting a timestamp in a dedicated column.
|
|
185
|
+
*
|
|
186
|
+
* This feature is particularly useful when you want to retain a record of deleted data and potentially recover it later,
|
|
187
|
+
* or when you want to maintain referential integrity in your database
|
|
139
188
|
* @param {string?} column default deleted_at
|
|
189
|
+
* @return {this} this
|
|
140
190
|
* @example
|
|
141
191
|
* class User extends Model {
|
|
142
192
|
* constructor() {
|
|
143
193
|
* this.useSoftDelete('deletedAt')
|
|
144
194
|
* }
|
|
145
195
|
* }
|
|
146
|
-
* @return {this} this
|
|
147
196
|
*/
|
|
148
197
|
protected useSoftDelete(column?: string): this;
|
|
149
198
|
/**
|
|
150
|
-
*
|
|
151
|
-
*
|
|
199
|
+
* The "useTimestamp" method is used to assign a timestamp when creating a new record,
|
|
200
|
+
* or updating a record.
|
|
152
201
|
* @param {object} timestampFormat
|
|
153
202
|
* @property {string} timestampFormat.createdAt - change new name column replace by default [created at]
|
|
154
203
|
* @property {string} timestampFormat.updatedAt - change new name column replace by default updated at
|
|
204
|
+
* @return {this} this
|
|
155
205
|
* @example
|
|
156
206
|
* class User extends Model {
|
|
157
207
|
* constructor() {
|
|
@@ -161,92 +211,127 @@ declare class Model extends AbstractModel {
|
|
|
161
211
|
* })
|
|
162
212
|
* }
|
|
163
213
|
* }
|
|
164
|
-
* @return {this} this
|
|
165
214
|
*/
|
|
166
215
|
protected useTimestamp(timestampFormat?: {
|
|
167
216
|
createdAt: string;
|
|
168
217
|
updatedAt: string;
|
|
169
218
|
}): this;
|
|
170
219
|
/**
|
|
171
|
-
*
|
|
172
|
-
* Assign table name in model
|
|
220
|
+
* This "useTable" method is used to assign the name of the table.
|
|
173
221
|
* @param {string} table table name in database
|
|
222
|
+
* @return {this} this
|
|
174
223
|
* @example
|
|
175
224
|
* class User extends Model {
|
|
176
225
|
* constructor() {
|
|
177
226
|
* this.useTable('setTableNameIsUser') // => 'setTableNameIsUser'
|
|
178
227
|
* }
|
|
179
228
|
* }
|
|
180
|
-
* @return {this} this
|
|
181
229
|
*/
|
|
182
230
|
protected useTable(table: string): this;
|
|
183
231
|
/**
|
|
184
|
-
*
|
|
185
|
-
*
|
|
232
|
+
* This "useTableSingular" method is used to assign the name of the table with signgular pattern.
|
|
233
|
+
* @return {this} this
|
|
186
234
|
* @example
|
|
187
235
|
* class User extends Model {
|
|
188
236
|
* constructor() {
|
|
189
237
|
* this.useTableSingular() // => 'user'
|
|
190
238
|
* }
|
|
191
239
|
* }
|
|
192
|
-
* @return {this} this
|
|
193
240
|
*/
|
|
194
241
|
protected useTableSingular(): this;
|
|
195
242
|
/**
|
|
196
|
-
*
|
|
197
|
-
*
|
|
243
|
+
* This "useTablePlural " method is used to assign the name of the table with pluarl pattern
|
|
244
|
+
* @return {this} this
|
|
198
245
|
* @example
|
|
199
246
|
* class User extends Model {
|
|
200
247
|
* constructor() {
|
|
201
248
|
* this.useTablePlural() // => 'users'
|
|
202
249
|
* }
|
|
203
250
|
* }
|
|
204
|
-
* @return {this} this
|
|
205
251
|
*/
|
|
206
252
|
protected useTablePlural(): this;
|
|
207
253
|
/**
|
|
208
|
-
*
|
|
209
|
-
*
|
|
210
|
-
* @
|
|
254
|
+
* This 'useValidationSchema' method is used to validate the schema when have some action create or update.
|
|
255
|
+
* @param {Object<ValidateSchema>} schema types (String Number and Date)
|
|
256
|
+
* @return {this} this
|
|
211
257
|
* @example
|
|
212
258
|
* class User extends Model {
|
|
213
259
|
* constructor() {
|
|
214
|
-
* this.useValidationSchema(
|
|
215
|
-
*
|
|
260
|
+
* this.useValidationSchema({
|
|
261
|
+
* id : Number,
|
|
262
|
+
* uuid : Number,
|
|
263
|
+
* name : {
|
|
264
|
+
* type : String,
|
|
265
|
+
* require : true
|
|
266
|
+
* // json : true,
|
|
267
|
+
* // enum : ["1","2","3"]
|
|
268
|
+
* },
|
|
269
|
+
* email : {
|
|
270
|
+
* type : String,
|
|
271
|
+
* require : true,
|
|
272
|
+
* length : 199,
|
|
273
|
+
* match: /^[a-zA-Z0-9._]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/,
|
|
274
|
+
* unique : true,
|
|
275
|
+
* fn : async (email : string) => /^[a-zA-Z0-9._]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/.test(email)
|
|
276
|
+
* },
|
|
277
|
+
* createdAt : Date,
|
|
278
|
+
* updatedAt : Date,
|
|
279
|
+
* deletedAt : Date
|
|
280
|
+
* })
|
|
281
|
+
* }
|
|
216
282
|
* }
|
|
217
|
-
* @return {this} this
|
|
218
283
|
*/
|
|
219
|
-
protected useValidationSchema(schema?:
|
|
284
|
+
protected useValidationSchema(schema?: ValidateSchema): this;
|
|
220
285
|
/**
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
286
|
+
* This 'useValidateSchema' method is used to validate the schema when have some action create or update.
|
|
287
|
+
* @param {Object<ValidateSchema>} schema types (String Number and Date)
|
|
288
|
+
* @return {this} this
|
|
289
|
+
* @example
|
|
290
|
+
* class User extends Model {
|
|
291
|
+
* constructor() {
|
|
292
|
+
* this.useValidationSchema({
|
|
293
|
+
* id : Number,
|
|
294
|
+
* uuid : string,
|
|
295
|
+
* name : {
|
|
296
|
+
* type : String,
|
|
297
|
+
* require : true
|
|
298
|
+
* },
|
|
299
|
+
* email : {
|
|
300
|
+
* type : String,
|
|
301
|
+
* require : true,
|
|
302
|
+
* length : 199,
|
|
303
|
+
* // json : true,
|
|
304
|
+
* // enum : ["1","2","3"]
|
|
305
|
+
* match: /^[a-zA-Z0-9._]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/,
|
|
306
|
+
* unique : true,
|
|
307
|
+
* fn : async (email : string) => /^[a-zA-Z0-9._]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/.test(email)
|
|
308
|
+
* },
|
|
309
|
+
* createdAt : Date,
|
|
310
|
+
* updatedAt : Date,
|
|
311
|
+
* deletedAt : Date
|
|
312
|
+
* })
|
|
313
|
+
* }
|
|
314
|
+
* }
|
|
315
|
+
*/
|
|
316
|
+
protected useValidateSchema(schema?: ValidateSchema): this;
|
|
233
317
|
/**
|
|
234
|
-
*
|
|
235
|
-
* @param {
|
|
318
|
+
* The "useHooks" method is used to assign hook function when execute returned results to callback function.
|
|
319
|
+
* @param {Function[]} arrayFunctions functions for callback result
|
|
320
|
+
* @return {this} this
|
|
236
321
|
* @example
|
|
237
322
|
* class User extends Model {
|
|
238
323
|
* constructor() {
|
|
239
324
|
* this.useHook([(results) => console.log(results)])
|
|
240
325
|
* }
|
|
241
326
|
* }
|
|
242
|
-
* @return {this}
|
|
243
327
|
*/
|
|
244
|
-
protected useHooks(arrayFunctions:
|
|
328
|
+
protected useHooks(arrayFunctions: Function[]): this;
|
|
245
329
|
/**
|
|
246
330
|
* exceptColumns for method except
|
|
331
|
+
* @override
|
|
247
332
|
* @return {promise<string>} string
|
|
248
333
|
*/
|
|
249
|
-
protected
|
|
334
|
+
protected _exceptColumns(): Promise<string[]>;
|
|
250
335
|
/**
|
|
251
336
|
* Build method for relation in model
|
|
252
337
|
* @param {string} name name relation registry in your model
|
|
@@ -260,7 +345,7 @@ declare class Model extends AbstractModel {
|
|
|
260
345
|
* @param {Model} instance instance of model
|
|
261
346
|
* @return {this} this
|
|
262
347
|
*/
|
|
263
|
-
|
|
348
|
+
clone(instance: Model): this;
|
|
264
349
|
/**
|
|
265
350
|
*
|
|
266
351
|
* Copy an instance of model
|
|
@@ -268,13 +353,17 @@ declare class Model extends AbstractModel {
|
|
|
268
353
|
* @param {Object} options keep data
|
|
269
354
|
* @return {Model} Model
|
|
270
355
|
*/
|
|
271
|
-
|
|
356
|
+
copyModel(instance: Model, options?: {
|
|
272
357
|
update?: boolean;
|
|
273
358
|
insert?: boolean;
|
|
274
359
|
delete?: boolean;
|
|
275
360
|
where?: boolean;
|
|
276
361
|
limit?: boolean;
|
|
362
|
+
orderBy?: boolean;
|
|
363
|
+
join?: boolean;
|
|
277
364
|
offset?: boolean;
|
|
365
|
+
groupBy?: boolean;
|
|
366
|
+
select?: boolean;
|
|
278
367
|
}): Model;
|
|
279
368
|
/**
|
|
280
369
|
*
|
|
@@ -283,17 +372,17 @@ declare class Model extends AbstractModel {
|
|
|
283
372
|
* @param {string} sql
|
|
284
373
|
* @return {this} this
|
|
285
374
|
*/
|
|
286
|
-
protected
|
|
375
|
+
protected _queryStatement(sql: string): Promise<any[]>;
|
|
287
376
|
/**
|
|
288
377
|
*
|
|
289
378
|
* execute the query using raw sql syntax actions for insert update and delete
|
|
290
379
|
* @override method
|
|
291
380
|
* @param {Object} actions
|
|
292
|
-
* @property {Function} actions.
|
|
381
|
+
* @property {Function} actions.sqlresult
|
|
293
382
|
* @property {Function} actions.returnId
|
|
294
383
|
* @return {this} this
|
|
295
384
|
*/
|
|
296
|
-
protected
|
|
385
|
+
protected _actionStatement({ sql, returnId }: {
|
|
297
386
|
sql: string;
|
|
298
387
|
returnId?: boolean;
|
|
299
388
|
}): Promise<any>;
|
|
@@ -302,7 +391,7 @@ declare class Model extends AbstractModel {
|
|
|
302
391
|
* @param {string} table table name
|
|
303
392
|
* @return {this} this
|
|
304
393
|
*/
|
|
305
|
-
|
|
394
|
+
table(table: string): this;
|
|
306
395
|
/**
|
|
307
396
|
* Assign ignore delete_at in model
|
|
308
397
|
* @param {boolean} condition
|
|
@@ -322,9 +411,11 @@ declare class Model extends AbstractModel {
|
|
|
322
411
|
*/
|
|
323
412
|
registry(func: Record<string, Function>): this;
|
|
324
413
|
/**
|
|
414
|
+
* The 'with' method is used to eager load related (relations) data when retrieving records from a database.
|
|
325
415
|
*
|
|
326
|
-
*
|
|
416
|
+
* Eager loading allows you to retrieve a primary model and its related models in a more efficient
|
|
327
417
|
* @param {...string} nameRelations ...name registry in models using (hasOne , hasMany , belongsTo , belongsToMany)
|
|
418
|
+
* @return {this} this
|
|
328
419
|
* @example
|
|
329
420
|
* import { Model } from 'tspace-mysql'
|
|
330
421
|
* class User extends Model {
|
|
@@ -341,29 +432,36 @@ declare class Model extends AbstractModel {
|
|
|
341
432
|
* this.belongsTo({ name : 'user' , model : User })
|
|
342
433
|
* }
|
|
343
434
|
* }
|
|
344
|
-
* // use with for results of relationship
|
|
345
|
-
* await new User().
|
|
346
|
-
*
|
|
435
|
+
* // use 'with' for results of relationship
|
|
436
|
+
* await new User().relations('posts').findMany()
|
|
437
|
+
*
|
|
347
438
|
*/
|
|
348
|
-
with(...nameRelations:
|
|
439
|
+
with(...nameRelations: string[]): this;
|
|
349
440
|
/**
|
|
441
|
+
* The 'withAll' method is used to eager load related (relations) data when retrieving records from a database.
|
|
350
442
|
*
|
|
351
|
-
*
|
|
443
|
+
* Eager loading allows you to retrieve a primary model and its related models in a more efficient
|
|
444
|
+
* It's method ignore soft delete
|
|
352
445
|
* @param {...string} nameRelations if data exists return blank
|
|
353
446
|
* @return {this} this
|
|
354
447
|
*/
|
|
355
|
-
withAll(...nameRelations:
|
|
448
|
+
withAll(...nameRelations: string[]): this;
|
|
356
449
|
/**
|
|
450
|
+
* The 'withTrashed' method is used to eager load related (relations) data when retrieving records from a database.
|
|
357
451
|
*
|
|
358
|
-
*
|
|
452
|
+
* Eager loading allows you to retrieve a primary model and its related models in a more efficient
|
|
453
|
+
* It's method return results only in trash (soft deleted)
|
|
359
454
|
* @param {...string} nameRelations if data exists return blank
|
|
360
455
|
* @return {this} this
|
|
361
456
|
*/
|
|
362
|
-
withTrashed(...nameRelations:
|
|
457
|
+
withTrashed(...nameRelations: string[]): this;
|
|
363
458
|
/**
|
|
459
|
+
* The 'withExists' method is used to eager load related (relations) data when retrieving records from a database.
|
|
364
460
|
*
|
|
365
|
-
*
|
|
366
|
-
*
|
|
461
|
+
* Eager loading allows you to retrieve a primary model and its related models in a more efficient
|
|
462
|
+
* It's method return only exists result of relation query
|
|
463
|
+
* @param {...string} nameRelations
|
|
464
|
+
* @return {this} this
|
|
367
465
|
* @example
|
|
368
466
|
* import { Model } from 'tspace-mysql'
|
|
369
467
|
* class User extends Model {
|
|
@@ -381,10 +479,9 @@ declare class Model extends AbstractModel {
|
|
|
381
479
|
* }
|
|
382
480
|
* }
|
|
383
481
|
* // use with for results of relationship if relations is exists
|
|
384
|
-
* await new User().
|
|
385
|
-
* @return {this} this
|
|
482
|
+
* await new User().relationsExists('posts').findMany()
|
|
386
483
|
*/
|
|
387
|
-
withExists(...nameRelations:
|
|
484
|
+
withExists(...nameRelations: string[]): this;
|
|
388
485
|
/**
|
|
389
486
|
*
|
|
390
487
|
* Use relations in registry of model return only exists result of relation query
|
|
@@ -409,10 +506,12 @@ declare class Model extends AbstractModel {
|
|
|
409
506
|
* await new User().has('posts').findMany()
|
|
410
507
|
* @return {this} this
|
|
411
508
|
*/
|
|
412
|
-
has(...nameRelations:
|
|
509
|
+
has(...nameRelations: string[]): this;
|
|
413
510
|
/**
|
|
414
511
|
*
|
|
415
|
-
*
|
|
512
|
+
* The 'withQuery' method is particularly useful when you want to filter or add conditions records based on related data.
|
|
513
|
+
*
|
|
514
|
+
* Use relation '${name}' registry models then return callback queries
|
|
416
515
|
* @param {string} nameRelation name relation in registry in your model
|
|
417
516
|
* @param {function} callback query callback
|
|
418
517
|
* @example
|
|
@@ -440,15 +539,15 @@ declare class Model extends AbstractModel {
|
|
|
440
539
|
* }
|
|
441
540
|
* }
|
|
442
541
|
*
|
|
443
|
-
* await new User().
|
|
444
|
-
* .
|
|
445
|
-
* return query.
|
|
446
|
-
* .
|
|
447
|
-
* return query.
|
|
542
|
+
* await new User().relations('posts')
|
|
543
|
+
* .relationsQuery('posts', (query : Post) => {
|
|
544
|
+
* return query.relations('comments','user')
|
|
545
|
+
* .relationsQuery('comments', (query : Comment) => {
|
|
546
|
+
* return query.relations('user','post')
|
|
448
547
|
* })
|
|
449
|
-
* .
|
|
450
|
-
* return query.
|
|
451
|
-
* return query.
|
|
548
|
+
* .relationsQuery('user', (query : User) => {
|
|
549
|
+
* return query.relations('posts').relationsQuery('posts',(query : Post)=> {
|
|
550
|
+
* return query.relations('comments','user')
|
|
452
551
|
* // relation n, n, ...n
|
|
453
552
|
* })
|
|
454
553
|
* })
|
|
@@ -481,7 +580,7 @@ declare class Model extends AbstractModel {
|
|
|
481
580
|
* await new User().relations('posts').findMany()
|
|
482
581
|
* @return {this} this
|
|
483
582
|
*/
|
|
484
|
-
relations(...nameRelations:
|
|
583
|
+
relations(...nameRelations: string[]): this;
|
|
485
584
|
/**
|
|
486
585
|
*
|
|
487
586
|
* Use relations in registry of model return only exists result of relation query
|
|
@@ -506,7 +605,7 @@ declare class Model extends AbstractModel {
|
|
|
506
605
|
* await new User().relationsExists('posts').findMany()
|
|
507
606
|
* @return {this} this
|
|
508
607
|
*/
|
|
509
|
-
relationsExists(...nameRelations:
|
|
608
|
+
relationsExists(...nameRelations: string[]): this;
|
|
510
609
|
/**
|
|
511
610
|
*
|
|
512
611
|
* Use relation '${name}' registry of model return callback this query model
|
|
@@ -537,15 +636,15 @@ declare class Model extends AbstractModel {
|
|
|
537
636
|
* }
|
|
538
637
|
* }
|
|
539
638
|
*
|
|
540
|
-
* await new User().
|
|
639
|
+
* await new User().relations('posts')
|
|
541
640
|
* .relationQuery('posts', (query : Post) => {
|
|
542
|
-
* return query.
|
|
641
|
+
* return query.relations('comments','user')
|
|
543
642
|
* .relationQuery('comments', (query : Comment) => {
|
|
544
|
-
* return query.
|
|
643
|
+
* return query.relations('user','post')
|
|
545
644
|
* })
|
|
546
645
|
* .relationQuery('user', (query : User) => {
|
|
547
|
-
* return query.
|
|
548
|
-
* return query.
|
|
646
|
+
* return query.relations('posts').relationQuery('posts',(query : Post)=> {
|
|
647
|
+
* return query.relations('comments','user')
|
|
549
648
|
* // relation n, n, ...n
|
|
550
649
|
* })
|
|
551
650
|
* })
|
|
@@ -560,16 +659,21 @@ declare class Model extends AbstractModel {
|
|
|
560
659
|
* @param {...string} nameRelations if data exists return blank
|
|
561
660
|
* @return {this} this
|
|
562
661
|
*/
|
|
563
|
-
relationsAll(...nameRelations:
|
|
662
|
+
relationsAll(...nameRelations: string[]): this;
|
|
564
663
|
/**
|
|
565
664
|
*
|
|
566
665
|
* Use relations in registry of model return only in trash (soft delete)
|
|
567
666
|
* @param {...string} nameRelations if data exists return blank
|
|
568
667
|
* @return {this} this
|
|
569
668
|
*/
|
|
570
|
-
relationsTrashed(...nameRelations:
|
|
669
|
+
relationsTrashed(...nameRelations: string[]): this;
|
|
571
670
|
/**
|
|
572
|
-
*
|
|
671
|
+
* The 'hasOne' relationship defines a one-to-one relationship between two database tables.
|
|
672
|
+
*
|
|
673
|
+
* It indicates that a particular record in the primary table is associated with one and only one record in the related table.
|
|
674
|
+
*
|
|
675
|
+
* This is typically used when you have a foreign key in the related table that references the primary table.
|
|
676
|
+
*
|
|
573
677
|
* @param {object} relations registry relation in your model
|
|
574
678
|
* @property {string} relation.name
|
|
575
679
|
* @property {string} relation.as
|
|
@@ -581,7 +685,12 @@ declare class Model extends AbstractModel {
|
|
|
581
685
|
*/
|
|
582
686
|
protected hasOne({ name, as, model, localKey, foreignKey, freezeTable }: Relation): this;
|
|
583
687
|
/**
|
|
584
|
-
*
|
|
688
|
+
* The 'hasMany' relationship defines a one-to-many relationship between two database tables.
|
|
689
|
+
*
|
|
690
|
+
* It indicates that a record in the primary table can be associated with multiple records in the related table.
|
|
691
|
+
*
|
|
692
|
+
* This is typically used when you have a foreign key in the related table that references the primary table.
|
|
693
|
+
*
|
|
585
694
|
* @param {object} relations registry relation in your model
|
|
586
695
|
* @property {string} relation.name
|
|
587
696
|
* @property {string} relation.as
|
|
@@ -593,7 +702,12 @@ declare class Model extends AbstractModel {
|
|
|
593
702
|
*/
|
|
594
703
|
protected hasMany({ name, as, model, localKey, foreignKey, freezeTable }: Relation): this;
|
|
595
704
|
/**
|
|
596
|
-
*
|
|
705
|
+
* The 'belongsTo' relationship defines a one-to-one or many-to-one relationship between two database tables.
|
|
706
|
+
*
|
|
707
|
+
* It indicates that a record in the related table belongs to a single record in the primary table.
|
|
708
|
+
*
|
|
709
|
+
* This is typically used when you have a foreign key in the primary table that references the related table.
|
|
710
|
+
*
|
|
597
711
|
* @param {object} relations registry relation in your model
|
|
598
712
|
* @property {string} relation.name
|
|
599
713
|
* @property {string} relation.as
|
|
@@ -605,7 +719,12 @@ declare class Model extends AbstractModel {
|
|
|
605
719
|
*/
|
|
606
720
|
protected belongsTo({ name, as, model, localKey, foreignKey, freezeTable }: Relation): this;
|
|
607
721
|
/**
|
|
608
|
-
*
|
|
722
|
+
* The 'belongsToMany' relationship defines a many-to-many relationship between two database tables.
|
|
723
|
+
*
|
|
724
|
+
* It indicates that records in both the primary table and the related table can be associated
|
|
725
|
+
* with multiple records in each other's table through an intermediate table.
|
|
726
|
+
*
|
|
727
|
+
* This is commonly used when you have a many-to-many relationship between entities, such as users and roles or products and categories.
|
|
609
728
|
* @param {object} relations registry relation in your model
|
|
610
729
|
* @property {string} relation.name
|
|
611
730
|
* @property {string} relation.as
|
|
@@ -615,25 +734,28 @@ declare class Model extends AbstractModel {
|
|
|
615
734
|
* @property {string} relation.freezeTable freeae table name
|
|
616
735
|
* @property {string} relation.pivot table name of pivot
|
|
617
736
|
* @property {string} relation.oldVersion return value of old version
|
|
737
|
+
* @property {class?} relation.modelPivot model for pivot
|
|
618
738
|
* @return {this} this
|
|
619
739
|
*/
|
|
620
|
-
protected belongsToMany({ name, as, model, localKey, foreignKey, freezeTable, pivot, oldVersion }: Relation): this;
|
|
740
|
+
protected belongsToMany({ name, as, model, localKey, foreignKey, freezeTable, pivot, oldVersion, modelPivot }: Relation): this;
|
|
621
741
|
/**
|
|
622
|
-
*
|
|
742
|
+
* The 'hasOneBuilder' method is useful for creating 'hasOne' relationship to function
|
|
743
|
+
*
|
|
623
744
|
* @param {object} relation registry relation in your model
|
|
624
745
|
* @type {object} relation
|
|
625
|
-
* @property {class}
|
|
746
|
+
* @property {class} model
|
|
626
747
|
* @property {string?} name
|
|
627
|
-
* @property {string?}
|
|
748
|
+
* @property {string?} as
|
|
628
749
|
* @property {string?} localKey
|
|
629
750
|
* @property {string?} foreignKey
|
|
630
751
|
* @property {string?} freezeTable
|
|
631
|
-
* @param {
|
|
752
|
+
* @param {Function?} callback callback of query
|
|
632
753
|
* @return {this} this
|
|
633
754
|
*/
|
|
634
755
|
protected hasOneBuilder({ name, as, model, localKey, foreignKey, freezeTable }: RelationQuery, callback?: Function): this;
|
|
635
756
|
/**
|
|
636
|
-
*
|
|
757
|
+
* The 'hasManyBuilder' method is useful for creating 'hasMany' relationship to function
|
|
758
|
+
*
|
|
637
759
|
* @param {object} relation registry relation in your model
|
|
638
760
|
* @type {object} relation
|
|
639
761
|
* @property {class} model
|
|
@@ -647,7 +769,7 @@ declare class Model extends AbstractModel {
|
|
|
647
769
|
*/
|
|
648
770
|
protected hasManyBuilder({ name, as, model, localKey, foreignKey, freezeTable }: RelationQuery, callback?: Function): this;
|
|
649
771
|
/**
|
|
650
|
-
*
|
|
772
|
+
* The 'belongsToBuilder' method is useful for creating 'belongsTo' relationship to function
|
|
651
773
|
* @param {object} relation registry relation in your model
|
|
652
774
|
* @type {object} relation
|
|
653
775
|
* @property {class} model
|
|
@@ -661,7 +783,7 @@ declare class Model extends AbstractModel {
|
|
|
661
783
|
*/
|
|
662
784
|
protected belongsToBuilder({ name, as, model, localKey, foreignKey, freezeTable }: RelationQuery, callback?: Function): this;
|
|
663
785
|
/**
|
|
664
|
-
*
|
|
786
|
+
* The 'belongsToManyBuilder' method is useful for creating 'belongsToMany' relationship to function
|
|
665
787
|
* @param {object} relation registry relation in your model
|
|
666
788
|
* @type {object} relation
|
|
667
789
|
* @property {class} model
|
|
@@ -673,23 +795,23 @@ declare class Model extends AbstractModel {
|
|
|
673
795
|
* @param {function?} callback callback of query
|
|
674
796
|
* @return {this} this
|
|
675
797
|
*/
|
|
676
|
-
protected belongsToManyBuilder({ name, as, model, localKey, foreignKey, freezeTable, pivot }: RelationQuery, callback?: Function): this;
|
|
798
|
+
protected belongsToManyBuilder({ name, as, model, localKey, foreignKey, freezeTable, pivot, oldVersion, modelPivot }: RelationQuery, callback?: Function): this;
|
|
677
799
|
/**
|
|
678
|
-
*
|
|
679
|
-
*
|
|
680
|
-
*
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
/**
|
|
684
|
-
* return only in trashed (data has been remove)
|
|
685
|
-
* @return {promise}
|
|
800
|
+
* The 'trashed' method is used to specify that you want to retrieve only the soft-deleted records from a database table.
|
|
801
|
+
*
|
|
802
|
+
* Soft deleting is a feature that allows you to mark records as deleted without physically removing them from the database. Instead,
|
|
803
|
+
* a special "deleted_at" timestamp column is set to a non-null value to indicate that the record has been deleted.
|
|
804
|
+
* @return {this} this
|
|
686
805
|
*/
|
|
687
|
-
|
|
806
|
+
onlyTrashed(): this;
|
|
688
807
|
/**
|
|
689
|
-
*
|
|
690
|
-
*
|
|
808
|
+
* The 'trashed' method is used to specify that you want to retrieve only the soft-deleted records from a database table.
|
|
809
|
+
*
|
|
810
|
+
* Soft deleting is a feature that allows you to mark records as deleted without physically removing them from the database. Instead,
|
|
811
|
+
* a special "deleted_at" timestamp column is set to a non-null value to indicate that the record has been deleted.
|
|
812
|
+
* @return {this} this
|
|
691
813
|
*/
|
|
692
|
-
|
|
814
|
+
trashed(): this;
|
|
693
815
|
/**
|
|
694
816
|
* restore data in trashed
|
|
695
817
|
* @return {promise}
|
|
@@ -698,54 +820,54 @@ declare class Model extends AbstractModel {
|
|
|
698
820
|
toTableName(): string;
|
|
699
821
|
toTableNameAndColumn(column: string): string;
|
|
700
822
|
/**
|
|
701
|
-
* delete data from the database
|
|
702
823
|
* @override Method
|
|
703
|
-
* @return {promise<boolean>}
|
|
824
|
+
* @return {promise<boolean>} promise boolean
|
|
704
825
|
*/
|
|
705
826
|
delete(): Promise<boolean>;
|
|
706
827
|
/**
|
|
707
|
-
*
|
|
708
828
|
* @override Method
|
|
709
|
-
* @return {promise<
|
|
829
|
+
* @return {promise<boolean>} promise boolean
|
|
830
|
+
*/
|
|
831
|
+
deleteMany(): Promise<boolean>;
|
|
832
|
+
/**
|
|
833
|
+
* @override Method
|
|
834
|
+
* @return {promise<Record<string,any> | null>} Record | null
|
|
710
835
|
*/
|
|
711
836
|
first(): Promise<Record<string, any> | null>;
|
|
712
837
|
/**
|
|
713
|
-
*
|
|
714
838
|
* @override Method
|
|
715
|
-
* @return {promise<Record<string,any> | null>}
|
|
839
|
+
* @return {promise<Record<string,any> | null>} Record | null
|
|
716
840
|
*/
|
|
717
841
|
findOne(): Promise<Record<string, any> | null>;
|
|
718
842
|
/**
|
|
719
|
-
*
|
|
720
843
|
* @override Method
|
|
721
|
-
* @return {promise<object | Error>}
|
|
844
|
+
* @return {promise<object | Error>} Record | throw error
|
|
722
845
|
*/
|
|
723
846
|
firstOrError(message: string, options?: Record<string, any>): Promise<Record<string, any>>;
|
|
724
847
|
/**
|
|
725
848
|
*
|
|
726
849
|
* @override Method
|
|
727
|
-
* @return {promise<any>}
|
|
850
|
+
* @return {promise<any>} Record | throw error
|
|
728
851
|
*/
|
|
729
852
|
findOneOrError(message: string, options?: Record<string, any>): Promise<Record<string, any>>;
|
|
730
853
|
/**
|
|
731
854
|
*
|
|
732
855
|
* @override Method
|
|
733
|
-
* @return {promise<array>}
|
|
856
|
+
* @return {promise<array>} Array
|
|
734
857
|
*/
|
|
735
858
|
get(): Promise<any[]>;
|
|
736
859
|
/**
|
|
737
860
|
*
|
|
738
861
|
* @override Method
|
|
739
|
-
* @return {promise<array>}
|
|
862
|
+
* @return {promise<array>} Array
|
|
740
863
|
*/
|
|
741
864
|
findMany(): Promise<any[]>;
|
|
742
865
|
/**
|
|
743
|
-
*
|
|
744
866
|
* @override Method
|
|
745
867
|
* @param {object?} paginationOptions by default page = 1 , limit = 15
|
|
746
868
|
* @property {number} paginationOptions.limit
|
|
747
869
|
* @property {number} paginationOptions.page
|
|
748
|
-
* @return {promise<Pagination>}
|
|
870
|
+
* @return {promise<Pagination>} Pagination
|
|
749
871
|
*/
|
|
750
872
|
pagination(paginationOptions?: {
|
|
751
873
|
limit?: number;
|
|
@@ -757,139 +879,127 @@ declare class Model extends AbstractModel {
|
|
|
757
879
|
* @param {?object} paginationOptions by default page = 1 , limit = 15
|
|
758
880
|
* @property {number} paginationOptions.limit
|
|
759
881
|
* @property {number} paginationOptions.page
|
|
760
|
-
* @return {promise<Pagination>}
|
|
882
|
+
* @return {promise<Pagination>} Pagination
|
|
761
883
|
*/
|
|
762
884
|
paginate(paginationOptions?: {
|
|
763
885
|
limit?: number;
|
|
764
886
|
page?: number;
|
|
765
887
|
}): Promise<Pagination>;
|
|
766
888
|
/**
|
|
767
|
-
*
|
|
768
889
|
* @override Method
|
|
769
890
|
* @param {string} column
|
|
770
|
-
* @return {Promise<array>}
|
|
891
|
+
* @return {Promise<array>} Array
|
|
771
892
|
*/
|
|
772
893
|
getGroupBy(column: string): Promise<any[]>;
|
|
773
894
|
/**
|
|
774
|
-
*
|
|
775
|
-
*
|
|
895
|
+
* @override Method
|
|
896
|
+
* @param {object} data for insert
|
|
897
|
+
* @return {this} this
|
|
898
|
+
*/
|
|
899
|
+
insert(data: Record<string, string | number | boolean | null | undefined>): this;
|
|
900
|
+
/**
|
|
901
|
+
* @override Method
|
|
902
|
+
* @param {object} data for insert
|
|
903
|
+
* @return {this} this
|
|
904
|
+
*/
|
|
905
|
+
create(data: Record<string, string | number | boolean | null | undefined>): this;
|
|
906
|
+
/**
|
|
907
|
+
* @override Method
|
|
776
908
|
* @param {object} data
|
|
777
909
|
* @param {array?} updateNotExists options for except update some records in your ${data}
|
|
778
910
|
* @return {this} this
|
|
779
911
|
*/
|
|
780
|
-
update(data: Record<string,
|
|
912
|
+
update(data: Record<string, string | number | boolean | null | undefined>, updateNotExists?: string[]): this;
|
|
781
913
|
/**
|
|
782
|
-
*
|
|
783
914
|
* @override Method
|
|
784
915
|
* @param {object} data
|
|
916
|
+
* @param {array?} updateNotExists options for except update some records in your ${data}
|
|
785
917
|
* @return {this} this
|
|
786
918
|
*/
|
|
787
|
-
|
|
788
|
-
length?: unknown;
|
|
789
|
-
}): this;
|
|
919
|
+
updateMany(data: Record<string, string | number | boolean | null | undefined>, updateNotExists?: string[]): this;
|
|
790
920
|
/**
|
|
791
|
-
*
|
|
792
921
|
* @override Method
|
|
793
|
-
* @param {object} data
|
|
922
|
+
* @param {object} data
|
|
794
923
|
* @return {this} this
|
|
795
924
|
*/
|
|
796
|
-
|
|
925
|
+
updateNotExists(data: Record<string, string | number | boolean | null | undefined> & {
|
|
926
|
+
length?: unknown;
|
|
927
|
+
}): this;
|
|
797
928
|
/**
|
|
798
|
-
*
|
|
799
929
|
* @override Method
|
|
800
|
-
* @param {object} data for
|
|
930
|
+
* @param {object} data for update or create
|
|
801
931
|
* @return {this} this
|
|
802
932
|
*/
|
|
803
|
-
|
|
933
|
+
updateOrCreate(data: Record<string, string | number | boolean | null | undefined>): this;
|
|
804
934
|
/**
|
|
805
|
-
*
|
|
806
935
|
* @override Method
|
|
807
936
|
* @param {object} data for update or create
|
|
808
937
|
* @return {this} this
|
|
809
938
|
*/
|
|
810
|
-
|
|
939
|
+
updateOrInsert(data: Record<string, string | number | boolean | null | undefined>): this;
|
|
811
940
|
/**
|
|
812
|
-
*
|
|
813
941
|
* @override Method
|
|
814
942
|
* @param {object} data for update or create
|
|
815
943
|
* @return {this} this
|
|
816
944
|
*/
|
|
817
|
-
|
|
945
|
+
insertOrUpdate(data: Record<string, string | number | boolean | null | undefined>): this;
|
|
818
946
|
/**
|
|
819
|
-
*
|
|
820
|
-
* @override Method
|
|
821
|
-
* @param {object} data for update or create
|
|
822
|
-
* @return {this} this
|
|
823
|
-
*/
|
|
824
|
-
insertOrUpdate(data: Record<string, any>): this;
|
|
825
|
-
/**
|
|
826
|
-
*
|
|
827
947
|
* @override Method
|
|
828
948
|
* @param {object} data for update or create
|
|
829
949
|
* @return {this} this
|
|
830
950
|
*/
|
|
831
|
-
createOrUpdate(data: Record<string,
|
|
951
|
+
createOrUpdate(data: Record<string, string | number | boolean | null | undefined>): this;
|
|
832
952
|
/**
|
|
833
|
-
*
|
|
834
953
|
* @override Method
|
|
835
954
|
* @param {object} data for create
|
|
836
955
|
* @return {this} this
|
|
837
956
|
*/
|
|
838
|
-
createOrSelect(data: Record<string,
|
|
839
|
-
/**
|
|
840
|
-
*
|
|
841
|
-
* @override Method
|
|
842
|
-
* @param {object} data for update or create
|
|
843
|
-
* @return {this} this
|
|
844
|
-
*/
|
|
845
|
-
insertOrSelect(data: Record<string, any>): this;
|
|
957
|
+
createOrSelect(data: Record<string, string | number | boolean | null | undefined>): this;
|
|
846
958
|
/**
|
|
847
|
-
*
|
|
848
|
-
* insert multiple data into the database
|
|
849
959
|
* @override Method
|
|
850
|
-
* @param {
|
|
851
|
-
* @return {this} this
|
|
960
|
+
* @param {object} data for update or create
|
|
961
|
+
* @return {this} this
|
|
852
962
|
*/
|
|
853
|
-
|
|
963
|
+
insertOrSelect(data: Record<string, string | number | boolean | null | undefined>): this;
|
|
854
964
|
/**
|
|
855
|
-
*
|
|
856
|
-
* insert muliple data into the database
|
|
857
965
|
* @override Method
|
|
858
|
-
* @param {
|
|
966
|
+
* @param {Record<string,any>[]} data create multiple data
|
|
859
967
|
* @return {this} this this
|
|
860
968
|
*/
|
|
861
|
-
|
|
969
|
+
createMultiple(data: Record<string, string | number | boolean | null | undefined>[]): this;
|
|
862
970
|
/**
|
|
863
971
|
*
|
|
864
|
-
* @param {object} data create not exists data
|
|
865
972
|
* @override Method
|
|
866
|
-
* @
|
|
973
|
+
* @param {Record<string,any>[]} data create multiple data
|
|
974
|
+
* @return {this} this
|
|
867
975
|
*/
|
|
868
|
-
|
|
976
|
+
insertMultiple(data: Record<string, string | number | boolean | null | undefined>[]): this;
|
|
869
977
|
/**
|
|
870
|
-
*
|
|
978
|
+
* @override Method
|
|
871
979
|
* @param {object} data create not exists data
|
|
980
|
+
* @return {this} this
|
|
981
|
+
*/
|
|
982
|
+
createNotExists(data: Record<string, string | number | boolean | null | undefined>): this;
|
|
983
|
+
/**
|
|
872
984
|
* @override Method
|
|
985
|
+
* @param {object} data create not exists data
|
|
873
986
|
* @return {this} this this
|
|
874
987
|
*/
|
|
875
|
-
insertNotExists(data: Record<string,
|
|
988
|
+
insertNotExists(data: Record<string, string | number | boolean | null | undefined>): this;
|
|
876
989
|
/**
|
|
877
990
|
*
|
|
878
991
|
* get schema from table
|
|
879
992
|
* @return {this} this this
|
|
880
993
|
*/
|
|
881
994
|
getSchema(): Promise<any>;
|
|
882
|
-
getSchemaModel():
|
|
883
|
-
getTableName(): any;
|
|
995
|
+
getSchemaModel(): Record<string, any> | null;
|
|
884
996
|
/**
|
|
885
|
-
*
|
|
886
997
|
* @override Method
|
|
887
998
|
* @return {Promise<Record<string,any> | any[] | null | undefined>}
|
|
888
999
|
*/
|
|
889
1000
|
save(): Promise<Record<string, any> | any[] | null | undefined>;
|
|
890
1001
|
/**
|
|
891
1002
|
*
|
|
892
|
-
* fake data into to this table
|
|
893
1003
|
* @override Method
|
|
894
1004
|
* @param {number} rows number of rows
|
|
895
1005
|
* @return {promise<any>}
|
|
@@ -899,25 +1009,23 @@ declare class Model extends AbstractModel {
|
|
|
899
1009
|
private _isPatternSnakeCase;
|
|
900
1010
|
private _classToTableName;
|
|
901
1011
|
private _makeTableName;
|
|
902
|
-
private _tableName;
|
|
903
|
-
private _valueInRelation;
|
|
904
1012
|
private _handleSoftDelete;
|
|
905
1013
|
/**
|
|
906
1014
|
*
|
|
907
1015
|
* generate sql statements
|
|
908
1016
|
* @override
|
|
909
|
-
* @return {string} string generated query string
|
|
910
1017
|
*/
|
|
911
|
-
protected
|
|
1018
|
+
protected _queryBuilder(): {
|
|
1019
|
+
select: () => string;
|
|
1020
|
+
insert: () => string;
|
|
1021
|
+
update: () => string;
|
|
1022
|
+
delete: () => string;
|
|
1023
|
+
any: () => string;
|
|
1024
|
+
};
|
|
912
1025
|
private _showOnly;
|
|
913
1026
|
private _validateSchema;
|
|
914
1027
|
private _execute;
|
|
915
1028
|
private _executeGroup;
|
|
916
|
-
private _relationMapData;
|
|
917
|
-
private _handleRelationsExists;
|
|
918
|
-
private _queryRelationsExists;
|
|
919
|
-
private _relation;
|
|
920
|
-
private _belongsToMany;
|
|
921
1029
|
private _pagination;
|
|
922
1030
|
private _returnEmpty;
|
|
923
1031
|
private _returnResult;
|
|
@@ -934,11 +1042,10 @@ declare class Model extends AbstractModel {
|
|
|
934
1042
|
private _insertOrSelectModel;
|
|
935
1043
|
private _updateModel;
|
|
936
1044
|
private _assertError;
|
|
937
|
-
private _functionRelationName;
|
|
938
|
-
private _handleRelations;
|
|
939
|
-
private _handleRelationsQuery;
|
|
940
1045
|
private _validateMethod;
|
|
941
1046
|
private _checkSchemaOrNextError;
|
|
1047
|
+
private _stoppedRetry;
|
|
1048
|
+
private _observer;
|
|
942
1049
|
private _initialModel;
|
|
943
1050
|
}
|
|
944
1051
|
export { Model };
|