tspace-mysql 1.2.9 → 1.3.1

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.
Files changed (56) hide show
  1. package/README.md +64 -14
  2. package/dist/cli/dump/db.d.ts +4 -4
  3. package/dist/cli/dump/db.js +25 -25
  4. package/dist/cli/generate/make.d.ts +4 -4
  5. package/dist/cli/generate/make.js +45 -45
  6. package/dist/cli/generate/model.d.ts +2 -2
  7. package/dist/cli/generate/model.js +6 -6
  8. package/dist/cli/index.d.ts +2 -2
  9. package/dist/cli/index.js +58 -58
  10. package/dist/cli/migrate/make.d.ts +4 -4
  11. package/dist/cli/migrate/make.js +30 -30
  12. package/dist/cli/models/make.d.ts +4 -4
  13. package/dist/cli/models/make.js +51 -51
  14. package/dist/cli/models/model.d.ts +2 -2
  15. package/dist/cli/models/model.js +20 -11
  16. package/dist/cli/query/index.d.ts +4 -4
  17. package/dist/cli/query/index.js +7 -7
  18. package/dist/cli/tables/make.d.ts +4 -4
  19. package/dist/cli/tables/make.js +26 -26
  20. package/dist/cli/tables/table.d.ts +2 -2
  21. package/dist/cli/tables/table.js +6 -6
  22. package/dist/lib/connection/index.d.ts +30 -30
  23. package/dist/lib/connection/index.js +144 -143
  24. package/dist/lib/connection/options.d.ts +15 -4
  25. package/dist/lib/connection/options.js +43 -42
  26. package/dist/lib/constants/index.d.ts +5 -8
  27. package/dist/lib/constants/index.js +162 -158
  28. package/dist/lib/index.d.ts +8 -8
  29. package/dist/lib/index.js +36 -36
  30. package/dist/lib/tspace/{AbstractDatabase.d.ts → AbstractBuilder.d.ts} +124 -116
  31. package/dist/lib/tspace/{AbstractDatabase.js → AbstractBuilder.js} +36 -34
  32. package/dist/lib/tspace/AbstractDB.d.ts +18 -18
  33. package/dist/lib/tspace/AbstractDB.js +11 -11
  34. package/dist/lib/tspace/AbstractModel.d.ts +41 -41
  35. package/dist/lib/tspace/AbstractModel.js +11 -11
  36. package/dist/lib/tspace/Blueprint.d.ts +136 -136
  37. package/dist/lib/tspace/Blueprint.js +228 -228
  38. package/dist/lib/tspace/{Database.d.ts → Builder.d.ts} +833 -706
  39. package/dist/lib/tspace/{Database.js → Builder.js} +2556 -2363
  40. package/dist/lib/tspace/DB.d.ts +152 -126
  41. package/dist/lib/tspace/DB.js +373 -264
  42. package/dist/lib/tspace/Interface.d.ts +110 -109
  43. package/dist/lib/tspace/Interface.js +2 -2
  44. package/dist/lib/tspace/Logger.d.ts +8 -8
  45. package/dist/lib/tspace/Logger.js +49 -49
  46. package/dist/lib/tspace/Model.d.ts +708 -609
  47. package/dist/lib/tspace/Model.js +2520 -2477
  48. package/dist/lib/tspace/ProxyHandler.d.ts +14 -14
  49. package/dist/lib/tspace/ProxyHandler.js +31 -31
  50. package/dist/lib/tspace/Schema.d.ts +8 -8
  51. package/dist/lib/tspace/Schema.js +45 -44
  52. package/dist/lib/tspace/index.d.ts +15 -15
  53. package/dist/lib/tspace/index.js +20 -20
  54. package/dist/lib/utils/index.d.ts +15 -15
  55. package/dist/lib/utils/index.js +155 -165
  56. package/package.json +2 -4
@@ -1,609 +1,708 @@
1
- import { AbstractModel } from './AbstractModel';
2
- import { Relation, Pagination, RelationQuery } from './Interface';
3
- declare class Model extends AbstractModel {
4
- constructor();
5
- /**
6
- *
7
- * define for initialize of models
8
- * @return {void} void
9
- */
10
- protected define(): void;
11
- /**
12
- *
13
- * Assign function callback in model
14
- * @return {this} this
15
- */
16
- protected useRegistry(): this;
17
- /**
18
- *
19
- * Assign primary column in model
20
- * @return {this} this
21
- */
22
- protected usePrimaryKey(primary: string): this;
23
- /**
24
- * Assign generate uuid when creating in model
25
- * @param {string?} column [column=uuid] make new name column for custom column replace uuid with this
26
- * @return {this} this
27
- */
28
- protected useUUID(column?: string): this;
29
- /**
30
- * Assign in model console.log raw sql when fetching query statement
31
- * @return {this} this
32
- */
33
- protected useDebug(): this;
34
- /**
35
- *
36
- * Assign in model use pattern [snake_case , camelCase]
37
- * @param {string} pattern
38
- * @return {this} this
39
- */
40
- protected usePattern(pattern: string): this;
41
- /**
42
- *
43
- * Assign in model show data not be deleted
44
- * Relations has reference this method
45
- * @param {string?} column
46
- * @return {this} this
47
- */
48
- protected useSoftDelete(column?: string): this;
49
- /**
50
- *
51
- * Assign timestamp when insert || updated created_at and update_at in table
52
- * @param {object} timestampFormat
53
- * @property {string} timestampFormat.createdAt - change new name column replace by default [created at]
54
- * @property {string} timestampFormat.updatedAt - change new name column replace by default updated at
55
- * @return {this} this
56
- */
57
- protected useTimestamp(timestampFormat?: {
58
- createdAt: string;
59
- updatedAt: string;
60
- }): this;
61
- /**
62
- *
63
- * Assign table name in model
64
- * @param {string} table table name in database
65
- * @return {this} this
66
- */
67
- protected useTable(table: string): this;
68
- /**
69
- *
70
- * Assign table name in model with signgular pattern
71
- * @return {this} this
72
- */
73
- protected useTableSingular(): this;
74
- /**
75
- *
76
- * Assign table name in model with pluarl pattern
77
- * @return {this} this
78
- */
79
- protected useTablePlural(): this;
80
- /**
81
- *
82
- * Assign schema column in model
83
- * @param {Object<Function>} schema type String Number and Date
84
- * @return {this} this
85
- */
86
- protected useSchema(schema: {
87
- [key: string]: Function;
88
- }): this;
89
- /**
90
- * Build method for relation in model
91
- * @param {string} name name relation registry in your model
92
- * @param {Function} callback query callback
93
- * @return {this} this
94
- */
95
- protected buildMethodRelation(name: string, callback?: Function): this;
96
- /**
97
- *
98
- * Clone instance of model
99
- * @param {Model} instance instance of model
100
- * @return {this} this
101
- */
102
- protected clone(instance: Model): this;
103
- /**
104
- *
105
- * Copy an instance of model
106
- * @param {Model} instance instance of model
107
- * @param {Object} options keep data
108
- * @return {Model} Model
109
- */
110
- protected copyModel(instance: Model, options?: {
111
- update?: boolean;
112
- insert?: boolean;
113
- delete?: boolean;
114
- where?: boolean;
115
- }): Model;
116
- /**
117
- * Assign ignore delete_at in model
118
- * @param {boolean} condition
119
- * @return {this} this
120
- */
121
- ignoreSoftDelete(condition?: boolean): this;
122
- /**
123
- * Assign ignore delete_at in model
124
- * @param {boolean} condition
125
- * @return {this} this
126
- */
127
- disableSoftDelete(condition?: boolean): this;
128
- /**
129
- * Assign build in function to result of data
130
- * @param {object} func
131
- * @return {this} this
132
- */
133
- registry(func: {
134
- [key: string]: Function;
135
- }): this;
136
- /**
137
- *
138
- * Use relations in registry of model return result of relation query
139
- * @param {...string} nameRelations ...name registry in models using (hasOne , hasMany , belongsTo , belongsToMany)
140
- * @return {this} this
141
- */
142
- with(...nameRelations: Array<string>): this;
143
- /**
144
- *
145
- * Use relations in registry of model return only exists result of relation query
146
- * @param {...string} nameRelations if data exists return blank
147
- * @return {this} this
148
- */
149
- withExists(...nameRelations: Array<string>): this;
150
- /**
151
- *
152
- * Use relations in registry of model return only exists result of relation query
153
- * @param {...string} nameRelations if data exists return blank
154
- * @return {this} this
155
- */
156
- has(...nameRelations: Array<string>): this;
157
- /**
158
- *
159
- * Use relation '${name}' registry of model return callback this query model
160
- * @param {string} nameRelation name relation in registry in your model
161
- * @param {function} callback query callback
162
- * @return {this} this
163
- */
164
- withQuery(nameRelation: string, callback: Function): this;
165
- /**
166
- *
167
- * Use relations in registry of model retrun result of relation query
168
- * @param {...string} nameRelations ...name registry in models using (hasOne , hasMany , belongsTo , belongsToMany)
169
- * @return {this} this
170
- */
171
- relations(...nameRelations: Array<string>): this;
172
- /**
173
- *
174
- * Use relations in registry of model return only exists result of relation query
175
- * @param {...string} nameRelations if data exists return blank
176
- * @return {this}
177
- */
178
- relationsExists(...nameRelations: Array<string>): this;
179
- /**
180
- *
181
- * Use relation '${name}' registry of model return callback this query model
182
- * @param {string} nameRelation name relation in registry in your model
183
- * @param {function} callback query callback
184
- * @return {this} this
185
- */
186
- relationQuery(nameRelation: string, callback: Function): this;
187
- /**
188
- * Assign the relation in model Objects
189
- * @param {object} relations registry relation in your model
190
- * @property {string} relation.name
191
- * @property {string} relation.as
192
- * @property {class} relation.model
193
- * @property {string} relation.localKey
194
- * @property {string} relation.foreignKey
195
- * @property {string} relation.freezeTable
196
- * @return {this} this
197
- */
198
- protected hasOne({ name, as, model, localKey, foreignKey, freezeTable }: Relation): this;
199
- /**
200
- * Assign the relation in model Objects
201
- * @param {object} relations registry relation in your model
202
- * @property {string} relation.name
203
- * @property {string} relation.as
204
- * @property {class} relation.model
205
- * @property {string} relation.localKey
206
- * @property {string} relation.foreignKey
207
- * @property {string} relation.freezeTable
208
- * @return {this} this
209
- */
210
- protected hasMany({ name, as, model, localKey, foreignKey, freezeTable }: Relation): this;
211
- /**
212
- * Assign the relation in model Objects
213
- * @param {object} relations registry relation in your model
214
- * @property {string} relation.name
215
- * @property {string} relation.as
216
- * @property {class} relation.model
217
- * @property {string} relation.localKey
218
- * @property {string} relation.foreignKey
219
- * @property {string} relation.freezeTable
220
- * @return {this} this
221
- */
222
- protected belongsTo({ name, as, model, localKey, foreignKey, freezeTable }: Relation): this;
223
- /**
224
- * Assign the relation in model Objects
225
- * @param {object} relations registry relation in your model
226
- * @property {string} relation.name
227
- * @property {string} relation.as
228
- * @property {class} relation.model
229
- * @property {string} relation.localKey
230
- * @property {string} relation.foreignKey
231
- * @property {string} relation.freezeTable
232
- * @return {this} this
233
- */
234
- protected belongsToMany({ name, as, model, localKey, foreignKey, freezeTable, pivot, oldVersion }: Relation): this;
235
- /**
236
- * Assign the relation in model Objects
237
- * @param {object} relation registry relation in your model
238
- * @type {object} relation
239
- * @property {class} model
240
- * @property {string?} name
241
- * @property {string?} as
242
- * @property {string?} localKey
243
- * @property {string?} foreignKey
244
- * @property {string?} freezeTable
245
- * @param {function?} callback callback of query
246
- * @return {this} this
247
- */
248
- protected hasOneBuilder({ name, as, model, localKey, foreignKey, freezeTable }: RelationQuery, callback?: Function): this;
249
- /**
250
- * Assign the relation in model Objects
251
- * @param {object} relation registry relation in your model
252
- * @type {object} relation
253
- * @property {class} model
254
- * @property {string?} name
255
- * @property {string?} as
256
- * @property {string?} localKey
257
- * @property {string?} foreignKey
258
- * @property {string?} freezeTable
259
- * @param {function?} callback callback of query
260
- * @return {this} this
261
- */
262
- protected hasManyBuilder({ name, as, model, localKey, foreignKey, freezeTable }: RelationQuery, callback?: Function): this;
263
- /**
264
- * Assign the relation in model Objects
265
- * @param {object} relation registry relation in your model
266
- * @type {object} relation
267
- * @property {class} model
268
- * @property {string?} name
269
- * @property {string?} as
270
- * @property {string?} localKey
271
- * @property {string?} foreignKey
272
- * @property {string?} freezeTable
273
- * @param {function?} callback callback of query
274
- * @return {this} this
275
- */
276
- protected belongsToBuilder({ name, as, model, localKey, foreignKey, freezeTable }: RelationQuery, callback?: Function): this;
277
- /**
278
- * Assign the relation in model Objects
279
- * @param {object} relation registry relation in your model
280
- * @type {object} relation
281
- * @property {class} model
282
- * @property {string?} name
283
- * @property {string?} as
284
- * @property {string?} localKey
285
- * @property {string?} foreignKey
286
- * @property {string?} freezeTable
287
- * @param {function?} callback callback of query
288
- * @return {this} this
289
- */
290
- protected belongsToManyBuilder({ name, as, model, localKey, foreignKey, freezeTable, pivot }: RelationQuery, callback?: Function): this;
291
- /**
292
- * return only in trashed (data has been remove)
293
- * @return {promise}
294
- */
295
- trashed(): Promise<any>;
296
- /**
297
- * return all only in trashed (data has been remove)
298
- * @return {promise}
299
- */
300
- onlyTrashed(): Promise<any>;
301
- /**
302
- * restore data in trashed
303
- * @return {promise}
304
- */
305
- restore(): Promise<any>;
306
- /**
307
- *
308
- * @override Method
309
- * @return {promise<string>}
310
- */
311
- exceptColumns(): Promise<string>;
312
- /**
313
- *
314
- * @override Method
315
- * @return {string}
316
- */
317
- toString(): string;
318
- /**
319
- *
320
- * @override Method
321
- * @return {string}
322
- */
323
- toSQL(): string;
324
- /**
325
- *
326
- * @override Method
327
- * @return {promise<string>}
328
- */
329
- toJSON(): Promise<string>;
330
- /**
331
- *
332
- * @override Method
333
- * @param {string=} column [column=id]
334
- * @return {promise<Array>}
335
- */
336
- toArray(column?: string): Promise<Array<any>>;
337
- /**
338
- *
339
- * @override Method
340
- * @param {string=} column [column=id]
341
- * @return {promise<number>}
342
- */
343
- avg(column?: string): Promise<number>;
344
- /**
345
- *
346
- * @override Method
347
- * @param {string} column [column=id]
348
- * @return {promise<number>}
349
- */
350
- sum(column?: string): Promise<number>;
351
- /**
352
- *
353
- * @override Method
354
- * @param {string=} column [column=id]
355
- * @return {promise<number>}
356
- */
357
- max(column?: string): Promise<number>;
358
- /**
359
- *
360
- * @override Method
361
- * @param {string=} column [column=id]
362
- * @return {promise<number>}
363
- */
364
- min(column?: string): Promise<number>;
365
- /**
366
- *
367
- * @override Method
368
- * @param {string=} column [column=id]
369
- * @return {promise<number>}
370
- */
371
- count(column?: string): Promise<number>;
372
- /**
373
- *
374
- * execute data return result is exists
375
- * @return {promise<boolean>}
376
- */
377
- exists(): Promise<boolean>;
378
- /**
379
- * delete data from the database
380
- * @override Method
381
- * @return {promise<boolean>}
382
- */
383
- delete(): Promise<boolean>;
384
- /**
385
- *
386
- * force delete data from the database
387
- * @return {promise<boolean>}
388
- */
389
- forceDelete(): Promise<boolean>;
390
- /**
391
- *
392
- * @override Method
393
- * @return {promise<any>}
394
- */
395
- first(): Promise<{
396
- [key: string]: any;
397
- } | null>;
398
- /**
399
- *
400
- * @override Method
401
- * @return {promise<any>}
402
- */
403
- findOne(): Promise<any>;
404
- /**
405
- *
406
- * @override Method
407
- * @return {promise<object | Error>}
408
- */
409
- firstOrError(message: string, options?: {
410
- [key: string]: any;
411
- }): Promise<{
412
- [key: string]: any;
413
- }>;
414
- /**
415
- *
416
- * @override Method
417
- * @return {promise<any>}
418
- */
419
- findOneOrError(message: string, options?: {
420
- [key: string]: any;
421
- }): Promise<{
422
- [key: string]: any;
423
- }>;
424
- /**
425
- *
426
- * @override Method
427
- * @return {promise<array>}
428
- */
429
- all(): Promise<Array<any>>;
430
- /**
431
- *
432
- * @override Method
433
- * @return {promise<object | null>}
434
- */
435
- find(id: number): Promise<any>;
436
- /**
437
- *
438
- * @override Method
439
- * @return {promise<array>}
440
- */
441
- get(): Promise<Array<any>>;
442
- /**
443
- *
444
- * @override Method
445
- * @return {promise<array>}
446
- */
447
- findMany(): Promise<Array<any>>;
448
- /**
449
- *
450
- * @override Method
451
- * @param {?object} paginationOptions by default page = 1 , limit = 15
452
- * @property {number} paginationOptions.limit
453
- * @property {number} paginationOptions.page
454
- * @return {promise<Pagination>}
455
- */
456
- pagination(paginationOptions?: {
457
- limit?: number;
458
- page?: number;
459
- }): Promise<Pagination>;
460
- /**
461
- *
462
- * @override Method
463
- * @param {?object} paginationOptions by default page = 1 , limit = 15
464
- * @property {number} paginationOptions.limit
465
- * @property {number} paginationOptions.page
466
- * @return {promise<Pagination>}
467
- */
468
- paginate(paginationOptions?: {
469
- limit?: number;
470
- page?: number;
471
- }): Promise<Pagination>;
472
- /**
473
- *
474
- * @override Method
475
- * @param {string} column
476
- * @return {Promise<array>}
477
- */
478
- getGroupBy(column: string): Promise<Array<any>>;
479
- /**
480
- *
481
- * update data in the database
482
- * @override Method
483
- * @param {object} data
484
- * @return {this} this
485
- */
486
- update(data: object): this;
487
- /**
488
- *
489
- * @override Method
490
- * @param {object} data for insert
491
- * @return {this} this
492
- */
493
- insert(data: object): this;
494
- /**
495
- *
496
- * @override Method
497
- * @param {object} data for insert
498
- * @return {this} this
499
- */
500
- create(data: object): this;
501
- /**
502
- *
503
- * @override Method
504
- * @param {object} data for update or create
505
- * @return {this} this
506
- */
507
- updateOrCreate(data: object): this;
508
- /**
509
- *
510
- * @override Method
511
- * @param {object} data for update or create
512
- * @return {this} this
513
- */
514
- updateOrInsert(data: object): this;
515
- /**
516
- *
517
- * @override Method
518
- * @param {object} data for update or create
519
- * @return {this} this
520
- */
521
- insertOrUpdate(data: object): this;
522
- /**
523
- *
524
- * @override Method
525
- * @param {object} data for update or create
526
- * @return {this} this
527
- */
528
- createOrUpdate(data: object): this;
529
- /**
530
- *
531
- * insert multiple data into the database
532
- * @override Method
533
- * @param {array<object>} data create multiple data
534
- * @return {this} this this
535
- */
536
- createMultiple(data: Array<Object>): this;
537
- /**
538
- *
539
- * insert muliple data into the database
540
- * @override Method
541
- * @param {array<object>} data create multiple data
542
- * @return {this} this this
543
- */
544
- insertMultiple(data: Array<Object>): this;
545
- /**
546
- *
547
- * @param {object} data create not exists data
548
- * @override Method
549
- * @return {this} this this
550
- */
551
- createNotExists(data: object): this;
552
- getSchema(): Promise<any>;
553
- /**
554
- *
555
- * @override Method
556
- * @return {Promise<any>}
557
- */
558
- save(): Promise<{
559
- [key: string]: any;
560
- } | Array<any> | null | undefined>;
561
- /**
562
- *
563
- * fake data
564
- * @param {number} rows number of rows
565
- * @return {promise<any>}
566
- */
567
- faker(rows?: number): Promise<{
568
- [key: string]: any;
569
- }[]>;
570
- private _valuePattern;
571
- private _isPatternSnakeCase;
572
- private _classToTableName;
573
- private _makeTableName;
574
- private _tableName;
575
- private _valueInRelation;
576
- private _handleSoftDelete;
577
- private _buildQueryModel;
578
- private _showOnly;
579
- private _validateSchema;
580
- private _execute;
581
- private _executeGroup;
582
- private _relationMapData;
583
- private _handleRelationsExists;
584
- private _queryRelationsExists;
585
- private _relation;
586
- private _belongsToMany;
587
- private _pagination;
588
- private _result;
589
- private _returnEmpty;
590
- private _returnResult;
591
- private _hiddenColumnModel;
592
- private _attach;
593
- private _detach;
594
- private _queryUpdateModel;
595
- private _queryInsertModel;
596
- private _queryInsertMultipleModel;
597
- private _insertNotExistsModel;
598
- private _createModel;
599
- private _createMultipleModel;
600
- private _updateOrInsertModel;
601
- private _updateModel;
602
- private _assertError;
603
- private _functionRelationName;
604
- private _handleRelationsQuery;
605
- private _validateMethod;
606
- private _initialModel;
607
- }
608
- export { Model };
609
- export default Model;
1
+ import { AbstractModel } from './AbstractModel';
2
+ import { Relation, Pagination, RelationQuery } from './Interface';
3
+ declare class Model extends AbstractModel {
4
+ constructor();
5
+ /**
6
+ *
7
+ * define for initialize of models
8
+ * @return {void} void
9
+ */
10
+ protected define(): void;
11
+ /**
12
+ *
13
+ * boot for initialize of models
14
+ * @return {void} void
15
+ */
16
+ protected boot(): void;
17
+ /**
18
+ *
19
+ * Assign function callback in model
20
+ * @return {this} this
21
+ */
22
+ protected useRegistry(): this;
23
+ /**
24
+ *
25
+ * Assign model calling all relationships in model
26
+ * @return {this} this
27
+ */
28
+ protected useLoadRelationInRegistry(): this;
29
+ /**
30
+ *
31
+ * Assign model built-in relation functions to a results
32
+ * @return {this} this
33
+ */
34
+ protected useBuiltInRelationFunctions(): this;
35
+ /**
36
+ *
37
+ * Assign primary column in model
38
+ * @return {this} this
39
+ */
40
+ protected usePrimaryKey(primary: string): this;
41
+ /**
42
+ * Assign generate uuid when creating in model
43
+ * @param {string?} column [column=uuid] make new name column for custom column replace uuid with this
44
+ * @return {this} this
45
+ */
46
+ protected useUUID(column?: string): this;
47
+ /**
48
+ * Assign in model console.log raw sql when fetching query statement
49
+ * @return {this} this
50
+ */
51
+ protected useDebug(): this;
52
+ /**
53
+ *
54
+ * Assign in model use pattern [snake_case , camelCase]
55
+ * @param {string} pattern
56
+ * @return {this} this
57
+ */
58
+ protected usePattern(pattern: string): this;
59
+ /**
60
+ *
61
+ * Assign in model show data not be deleted
62
+ * Relations has reference this method
63
+ * @param {string?} column
64
+ * @return {this} this
65
+ */
66
+ protected useSoftDelete(column?: string): this;
67
+ /**
68
+ *
69
+ * Assign timestamp when insert || updated created_at and update_at in table
70
+ * @param {object} timestampFormat
71
+ * @property {string} timestampFormat.createdAt - change new name column replace by default [created at]
72
+ * @property {string} timestampFormat.updatedAt - change new name column replace by default updated at
73
+ * @return {this} this
74
+ */
75
+ protected useTimestamp(timestampFormat?: {
76
+ createdAt: string;
77
+ updatedAt: string;
78
+ }): this;
79
+ /**
80
+ *
81
+ * Assign table name in model
82
+ * @param {string} table table name in database
83
+ * @return {this} this
84
+ */
85
+ protected useTable(table: string): this;
86
+ /**
87
+ *
88
+ * Assign table name in model with signgular pattern
89
+ * @return {this} this
90
+ */
91
+ protected useTableSingular(): this;
92
+ /**
93
+ *
94
+ * Assign table name in model with pluarl pattern
95
+ * @return {this} this
96
+ */
97
+ protected useTablePlural(): this;
98
+ /**
99
+ *
100
+ * Assign schema column in model for validation data types
101
+ * @param {Object<Function>} schema types (String Number and Date)
102
+ * @return {this} this
103
+ */
104
+ protected useSchema(schema: Record<string, Function>): this;
105
+ /**
106
+ * Assign hook function when execute returned results to callback function
107
+ * @param {Function} arrayFunction function for callback result
108
+ * @return {this}
109
+ */
110
+ protected useHook(functions: Array<Function>): this;
111
+ /**
112
+ * exceptColumns for method except
113
+ * @return {promise<string>} string
114
+ */
115
+ protected exceptColumns(): Promise<string>;
116
+ /**
117
+ * Build method for relation in model
118
+ * @param {string} name name relation registry in your model
119
+ * @param {Function} callback query callback
120
+ * @return {this} this
121
+ */
122
+ protected buildMethodRelation(name: string, callback?: Function): this;
123
+ /**
124
+ *
125
+ * Clone instance of model
126
+ * @param {Model} instance instance of model
127
+ * @return {this} this
128
+ */
129
+ protected clone(instance: Model): this;
130
+ /**
131
+ *
132
+ * Copy an instance of model
133
+ * @param {Model} instance instance of model
134
+ * @param {Object} options keep data
135
+ * @return {Model} Model
136
+ */
137
+ protected copyModel(instance: Model, options?: {
138
+ update?: boolean;
139
+ insert?: boolean;
140
+ delete?: boolean;
141
+ where?: boolean;
142
+ }): Model;
143
+ /**
144
+ * Assign ignore delete_at in model
145
+ * @param {boolean} condition
146
+ * @return {this} this
147
+ */
148
+ ignoreSoftDelete(condition?: boolean): this;
149
+ /**
150
+ * Assign table name
151
+ * @param {string} table table name
152
+ * @return {this} this
153
+ */
154
+ tableName(table: string): this;
155
+ /**
156
+ * Assign ignore delete_at in model
157
+ * @param {boolean} condition
158
+ * @return {this} this
159
+ */
160
+ disableSoftDelete(condition?: boolean): this;
161
+ /**
162
+ * Assign build in function to result of data
163
+ * @param {object} func
164
+ * @return {this} this
165
+ */
166
+ registry(func: {
167
+ [key: string]: Function;
168
+ }): this;
169
+ /**
170
+ *
171
+ * Use relations in registry of model return result of relation query
172
+ * @param {...string} nameRelations ...name registry in models using (hasOne , hasMany , belongsTo , belongsToMany)
173
+ * @return {this} this
174
+ */
175
+ with(...nameRelations: Array<string>): this;
176
+ /**
177
+ *
178
+ * Use relations in registry of model return ignore soft deleted
179
+ * @param {...string} nameRelations if data exists return blank
180
+ * @return {this} this
181
+ */
182
+ withTrashed(...nameRelations: Array<string>): this;
183
+ /**
184
+ *
185
+ * Use relations in registry of model return only exists result of relation query
186
+ * @param {...string} nameRelations if data exists return blank
187
+ * @return {this} this
188
+ */
189
+ withExists(...nameRelations: Array<string>): this;
190
+ /**
191
+ *
192
+ * Use relations in registry of model return only exists result of relation query
193
+ * @param {...string} nameRelations if data exists return blank
194
+ * @return {this} this
195
+ */
196
+ has(...nameRelations: Array<string>): this;
197
+ /**
198
+ *
199
+ * Use relation '${name}' registry of model return callback this query model
200
+ * @param {string} nameRelation name relation in registry in your model
201
+ * @param {function} callback query callback
202
+ * @return {this} this
203
+ */
204
+ withQuery(nameRelation: string, callback: Function): this;
205
+ /**
206
+ *
207
+ * Use relations in registry of model retrun result of relation query
208
+ * @param {...string} nameRelations ...name registry in models using (hasOne , hasMany , belongsTo , belongsToMany)
209
+ * @return {this} this
210
+ */
211
+ relations(...nameRelations: Array<string>): this;
212
+ /**
213
+ *
214
+ * Use relations in registry of model return only exists result of relation query
215
+ * @param {...string} nameRelations if data exists return blank
216
+ * @return {this}
217
+ */
218
+ relationsExists(...nameRelations: Array<string>): this;
219
+ /**
220
+ *
221
+ * Use relation '${name}' registry of model return callback this query model
222
+ * @param {string} nameRelation name relation in registry in your model
223
+ * @param {function} callback query callback
224
+ * @return {this} this
225
+ */
226
+ relationQuery(nameRelation: string, callback: Function): this;
227
+ /**
228
+ *
229
+ * Use relations in registry of model return ignore soft deleted
230
+ * @param {...string} nameRelations if data exists return blank
231
+ * @return {this} this
232
+ */
233
+ relationTrashed(...nameRelations: Array<string>): this;
234
+ /**
235
+ * Assign the relation in model Objects
236
+ * @param {object} relations registry relation in your model
237
+ * @property {string} relation.name
238
+ * @property {string} relation.as
239
+ * @property {class} relation.model
240
+ * @property {string} relation.localKey
241
+ * @property {string} relation.foreignKey
242
+ * @property {string} relation.freezeTable
243
+ * @return {this} this
244
+ */
245
+ protected hasOne({ name, as, model, localKey, foreignKey, freezeTable }: Relation): this;
246
+ /**
247
+ * Assign the relation in model Objects
248
+ * @param {object} relations registry relation in your model
249
+ * @property {string} relation.name
250
+ * @property {string} relation.as
251
+ * @property {class} relation.model
252
+ * @property {string} relation.localKey
253
+ * @property {string} relation.foreignKey
254
+ * @property {string} relation.freezeTable
255
+ * @return {this} this
256
+ */
257
+ protected hasMany({ name, as, model, localKey, foreignKey, freezeTable }: Relation): this;
258
+ /**
259
+ * Assign the relation in model Objects
260
+ * @param {object} relations registry relation in your model
261
+ * @property {string} relation.name
262
+ * @property {string} relation.as
263
+ * @property {class} relation.model
264
+ * @property {string} relation.localKey
265
+ * @property {string} relation.foreignKey
266
+ * @property {string} relation.freezeTable
267
+ * @return {this} this
268
+ */
269
+ protected belongsTo({ name, as, model, localKey, foreignKey, freezeTable }: Relation): this;
270
+ /**
271
+ * Assign the relation in model Objects
272
+ * @param {object} relations registry relation in your model
273
+ * @property {string} relation.name
274
+ * @property {string} relation.as
275
+ * @property {class} relation.model
276
+ * @property {string} relation.localKey
277
+ * @property {string} relation.foreignKey
278
+ * @property {string} relation.freezeTable freeae table name
279
+ * @property {string} relation.pivot table name of pivot
280
+ * @property {string} relation.oldVersion return value of old version
281
+ * @return {this} this
282
+ */
283
+ protected belongsToMany({ name, as, model, localKey, foreignKey, freezeTable, pivot, oldVersion }: Relation): this;
284
+ /**
285
+ * Assign the relation in model Objects
286
+ * @param {object} relation registry relation in your model
287
+ * @type {object} relation
288
+ * @property {class} model
289
+ * @property {string?} name
290
+ * @property {string?} as
291
+ * @property {string?} localKey
292
+ * @property {string?} foreignKey
293
+ * @property {string?} freezeTable
294
+ * @param {function?} callback callback of query
295
+ * @return {this} this
296
+ */
297
+ protected hasOneBuilder({ name, as, model, localKey, foreignKey, freezeTable }: RelationQuery, callback?: Function): this;
298
+ /**
299
+ * Assign the relation in model Objects
300
+ * @param {object} relation registry relation in your model
301
+ * @type {object} relation
302
+ * @property {class} model
303
+ * @property {string?} name
304
+ * @property {string?} as
305
+ * @property {string?} localKey
306
+ * @property {string?} foreignKey
307
+ * @property {string?} freezeTable
308
+ * @param {function?} callback callback of query
309
+ * @return {this} this
310
+ */
311
+ protected hasManyBuilder({ name, as, model, localKey, foreignKey, freezeTable }: RelationQuery, callback?: Function): this;
312
+ /**
313
+ * Assign the relation in model Objects
314
+ * @param {object} relation registry relation in your model
315
+ * @type {object} relation
316
+ * @property {class} model
317
+ * @property {string?} name
318
+ * @property {string?} as
319
+ * @property {string?} localKey
320
+ * @property {string?} foreignKey
321
+ * @property {string?} freezeTable
322
+ * @param {function?} callback callback of query
323
+ * @return {this} this
324
+ */
325
+ protected belongsToBuilder({ name, as, model, localKey, foreignKey, freezeTable }: RelationQuery, callback?: Function): this;
326
+ /**
327
+ * Assign the relation in model Objects
328
+ * @param {object} relation registry relation in your model
329
+ * @type {object} relation
330
+ * @property {class} model
331
+ * @property {string?} name
332
+ * @property {string?} as
333
+ * @property {string?} localKey
334
+ * @property {string?} foreignKey
335
+ * @property {string?} freezeTable
336
+ * @param {function?} callback callback of query
337
+ * @return {this} this
338
+ */
339
+ protected belongsToManyBuilder({ name, as, model, localKey, foreignKey, freezeTable, pivot }: RelationQuery, callback?: Function): this;
340
+ /**
341
+ * return only in trashed (data has been remove)
342
+ * @return {promise}
343
+ */
344
+ trashed(): Promise<any>;
345
+ /**
346
+ * return all only in trashed (data has been remove)
347
+ * @return {promise}
348
+ */
349
+ onlyTrashed(): Promise<any>;
350
+ /**
351
+ * restore data in trashed
352
+ * @return {promise}
353
+ */
354
+ restore(): Promise<any>;
355
+ toTableName(): string;
356
+ toTableNameAndColumn(column: string): string;
357
+ /**
358
+ *
359
+ * @override Method
360
+ * @return {string}
361
+ */
362
+ toString(): string;
363
+ /**
364
+ *
365
+ * @override Method
366
+ * @return {string}
367
+ */
368
+ toSQL(): string;
369
+ /**
370
+ *
371
+ * @override Method
372
+ * @return {promise<string>}
373
+ */
374
+ toJSON(): Promise<string>;
375
+ /**
376
+ *
377
+ * @override Method
378
+ * @param {string=} column [column=id]
379
+ * @return {promise<Array>}
380
+ */
381
+ toArray(column?: string): Promise<Array<any>>;
382
+ /**
383
+ *
384
+ * @override Method
385
+ * @param {string=} column [column=id]
386
+ * @return {promise<number>}
387
+ */
388
+ avg(column?: string): Promise<number>;
389
+ /**
390
+ *
391
+ * @override Method
392
+ * @param {string} column [column=id]
393
+ * @return {promise<number>}
394
+ */
395
+ sum(column?: string): Promise<number>;
396
+ /**
397
+ *
398
+ * @override Method
399
+ * @param {string=} column [column=id]
400
+ * @return {promise<number>}
401
+ */
402
+ max(column?: string): Promise<number>;
403
+ /**
404
+ *
405
+ * @override Method
406
+ * @param {string=} column [column=id]
407
+ * @return {promise<number>}
408
+ */
409
+ min(column?: string): Promise<number>;
410
+ /**
411
+ *
412
+ * @override Method
413
+ * @param {string=} column [column=id]
414
+ * @return {promise<number>}
415
+ */
416
+ count(column?: string): Promise<number>;
417
+ /**
418
+ *
419
+ * execute data return result is exists
420
+ * @return {promise<boolean>}
421
+ */
422
+ exists(): Promise<boolean>;
423
+ /**
424
+ * delete data from the database
425
+ * @override Method
426
+ * @return {promise<boolean>}
427
+ */
428
+ delete(): Promise<boolean>;
429
+ /**
430
+ *
431
+ * force delete data from the database
432
+ * @return {promise<boolean>}
433
+ */
434
+ forceDelete(): Promise<boolean>;
435
+ /**
436
+ *
437
+ * @override Method
438
+ * @return {promise<{[key: string]:any} | null>}
439
+ */
440
+ first(): Promise<{
441
+ [key: string]: any;
442
+ } | null>;
443
+ /**
444
+ *
445
+ * @override Method
446
+ * @return {promise<{[key: string]:any} | null>}
447
+ */
448
+ findOne(): Promise<{
449
+ [key: string]: any;
450
+ } | null>;
451
+ /**
452
+ *
453
+ * @override Method
454
+ * @return {promise<object | Error>}
455
+ */
456
+ firstOrError(message: string, options?: {
457
+ [key: string]: any;
458
+ }): Promise<{
459
+ [key: string]: any;
460
+ }>;
461
+ /**
462
+ *
463
+ * @override Method
464
+ * @return {promise<any>}
465
+ */
466
+ findOneOrError(message: string, options?: {
467
+ [key: string]: any;
468
+ }): Promise<{
469
+ [key: string]: any;
470
+ }>;
471
+ /**
472
+ *
473
+ * @override Method
474
+ * @return {promise<array>}
475
+ */
476
+ all(): Promise<Array<any>>;
477
+ /**
478
+ *
479
+ * @override Method
480
+ * @return {promise<object | null>}
481
+ */
482
+ find(id: number): Promise<Record<string, any> | null>;
483
+ /**
484
+ *
485
+ * @override Method
486
+ * @return {promise<array>}
487
+ */
488
+ get(): Promise<Array<any>>;
489
+ /**
490
+ *
491
+ * @override Method
492
+ * @return {promise<array>}
493
+ */
494
+ findMany(): Promise<Array<any>>;
495
+ /**
496
+ *
497
+ * @override Method
498
+ * @param {object?} paginationOptions by default page = 1 , limit = 15
499
+ * @property {number} paginationOptions.limit
500
+ * @property {number} paginationOptions.page
501
+ * @return {promise<Pagination>}
502
+ */
503
+ pagination(paginationOptions?: {
504
+ limit?: number;
505
+ page?: number;
506
+ }): Promise<Pagination>;
507
+ /**
508
+ *
509
+ * @override Method
510
+ * @param {?object} paginationOptions by default page = 1 , limit = 15
511
+ * @property {number} paginationOptions.limit
512
+ * @property {number} paginationOptions.page
513
+ * @return {promise<Pagination>}
514
+ */
515
+ paginate(paginationOptions?: {
516
+ limit?: number;
517
+ page?: number;
518
+ }): Promise<Pagination>;
519
+ /**
520
+ *
521
+ * @override Method
522
+ * @param {string} column
523
+ * @return {Promise<array>}
524
+ */
525
+ getGroupBy(column: string): Promise<Array<any>>;
526
+ /**
527
+ *
528
+ * update data in the database
529
+ * @override Method
530
+ * @param {object} data
531
+ * @return {this} this
532
+ */
533
+ update(data: Record<string, any> & {
534
+ length?: never;
535
+ }): this;
536
+ /**
537
+ *
538
+ * @override Method
539
+ * @param {object} data for insert
540
+ * @return {this} this
541
+ */
542
+ insert(data: Record<string, any> & {
543
+ length?: never;
544
+ }): this;
545
+ /**
546
+ *
547
+ * @override Method
548
+ * @param {object} data for insert
549
+ * @return {this} this
550
+ */
551
+ create(data: Record<string, any> & {
552
+ length?: never;
553
+ }): this;
554
+ /**
555
+ *
556
+ * @override Method
557
+ * @param {object} data for update or create
558
+ * @return {this} this
559
+ */
560
+ updateOrCreate(data: Record<string, any> & {
561
+ length?: never;
562
+ }): this;
563
+ /**
564
+ *
565
+ * @override Method
566
+ * @param {object} data for update or create
567
+ * @return {this} this
568
+ */
569
+ updateOrInsert(data: Record<string, any> & {
570
+ length?: never;
571
+ }): this;
572
+ /**
573
+ *
574
+ * @override Method
575
+ * @param {object} data for update or create
576
+ * @return {this} this
577
+ */
578
+ insertOrUpdate(data: Record<string, any> & {
579
+ length?: never;
580
+ }): this;
581
+ /**
582
+ *
583
+ * @override Method
584
+ * @param {object} data for update or create
585
+ * @return {this} this
586
+ */
587
+ createOrUpdate(data: Record<string, any> & {
588
+ length?: never;
589
+ }): this;
590
+ /**
591
+ *
592
+ * @override Method
593
+ * @param {object} data for create
594
+ * @return {this} this
595
+ */
596
+ createOrSelect(data: Record<string, any> & {
597
+ length?: never;
598
+ }): this;
599
+ /**
600
+ *
601
+ * @override Method
602
+ * @param {object} data for update or create
603
+ * @return {this} this
604
+ */
605
+ insertOrSelect(data: Record<string, any> & {
606
+ length?: never;
607
+ }): this;
608
+ /**
609
+ *
610
+ * insert multiple data into the database
611
+ * @override Method
612
+ * @param {array<object>} data create multiple data
613
+ * @return {this} this this
614
+ */
615
+ createMultiple(data: Array<{
616
+ [key: string]: any;
617
+ }>): this;
618
+ /**
619
+ *
620
+ * insert muliple data into the database
621
+ * @override Method
622
+ * @param {array<object>} data create multiple data
623
+ * @return {this} this this
624
+ */
625
+ insertMultiple(data: Array<{
626
+ [key: string]: any;
627
+ }>): this;
628
+ /**
629
+ *
630
+ * @param {object} data create not exists data
631
+ * @override Method
632
+ * @return {this} this this
633
+ */
634
+ createNotExists(data: Record<string, any> & {
635
+ length?: never;
636
+ }): this;
637
+ /**
638
+ *
639
+ * @param {object} data create not exists data
640
+ * @override Method
641
+ * @return {this} this this
642
+ */
643
+ insertNotExists(data: {
644
+ [key: string]: any;
645
+ } & {
646
+ length?: never;
647
+ }): this;
648
+ /**
649
+ *
650
+ * get schema of table
651
+ * @return {this} this this
652
+ */
653
+ getSchema(): Promise<any>;
654
+ /**
655
+ *
656
+ * @override Method
657
+ * @return {Promise<Record<string,any> | Array<any> | null | undefined>}
658
+ */
659
+ save(): Promise<Record<string, any> | Array<any> | null | undefined>;
660
+ /**
661
+ *
662
+ * fake data into to this table
663
+ * @param {number} rows number of rows
664
+ * @return {promise<any>}
665
+ */
666
+ faker(rows?: number): Promise<Record<string, any>[]>;
667
+ private _valuePattern;
668
+ private _isPatternSnakeCase;
669
+ private _classToTableName;
670
+ private _makeTableName;
671
+ private _tableName;
672
+ private _valueInRelation;
673
+ private _handleSoftDelete;
674
+ private _buildQueryModel;
675
+ private _showOnly;
676
+ private _validateSchema;
677
+ private _execute;
678
+ private _executeGroup;
679
+ private _relationMapData;
680
+ private _handleRelationsExists;
681
+ private _queryRelationsExists;
682
+ private _relation;
683
+ private _belongsToMany;
684
+ private _pagination;
685
+ private _result;
686
+ private _returnEmpty;
687
+ private _returnResult;
688
+ private _hiddenColumnModel;
689
+ private _attach;
690
+ private _detach;
691
+ private _queryUpdateModel;
692
+ private _queryInsertModel;
693
+ private _queryInsertMultipleModel;
694
+ private _insertNotExistsModel;
695
+ private _insertModel;
696
+ private _createMultipleModel;
697
+ private _updateOrInsertModel;
698
+ private _insertOrSelectModel;
699
+ private _updateModel;
700
+ private _assertError;
701
+ private _functionRelationName;
702
+ private _handleRelations;
703
+ private _handleRelationsQuery;
704
+ private _validateMethod;
705
+ private _initialModel;
706
+ }
707
+ export { Model };
708
+ export default Model;