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,706 +1,833 @@
1
- import AbstractDatabase from './AbstractDatabase';
2
- import { Pagination, Backup, ConnectionOptions, BackupToFile, Connection, ConnectionTransaction } from './Interface';
3
- declare class Database extends AbstractDatabase {
4
- constructor();
5
- /**
6
- *
7
- * @param {string} column
8
- * @return {this}
9
- */
10
- pluck(column: string): this;
11
- /**
12
- *
13
- * @param {...string} columns
14
- * @return {this} this
15
- */
16
- except(...columns: Array<string>): this;
17
- /**
18
- * data alaways will return void
19
- * @return {this} this
20
- */
21
- void(): this;
22
- /**
23
- *
24
- * @param {...string} columns show only colums selected
25
- * @return {this} this
26
- */
27
- only(...columns: Array<string>): this;
28
- /**
29
- *
30
- * @param {string=} column [column=id]
31
- * @return {this} this
32
- */
33
- distinct(column?: string): this;
34
- /**
35
- * select data form table
36
- * @param {Array<string>} ...columns
37
- * @return {this} this
38
- */
39
- select(...columns: Array<string>): this;
40
- /**
41
- * chunks data from array
42
- * @param {number} chunk
43
- * @return {this} this
44
- */
45
- chunk(chunk: number): this;
46
- /**
47
- *
48
- * @param {string | number | undefined | null | Boolean} condition when condition true will return query callback
49
- * @return {this} this
50
- */
51
- when(condition: string | number | undefined | null | Boolean, callback: Function): this;
52
- /**
53
- * if has 2 arguments default operator '='
54
- * @param {string} column
55
- * @param {string?} operator ['=', '<', '>' ,'!=', '!<', '!>' ,'LIKE']
56
- * @param {any?} value
57
- * @return {this}
58
- */
59
- resetWhere(): this;
60
- /**
61
- * if has 2 arguments default operator '='
62
- * @param {string} column
63
- * @param {string?} operator ['=', '<', '>' ,'!=', '!<', '!>' ,'LIKE']
64
- * @param {any?} value
65
- * @return {this}
66
- */
67
- where(column: string, operator?: any, value?: any): this;
68
- /**
69
- * where using object operator only '='
70
- * @param {Object} columns
71
- * @return {this}
72
- */
73
- whereObject(columns: {
74
- [key: string]: any;
75
- }): this;
76
- /**
77
- * if has 2 arguments default operator '='
78
- * @param {string} column
79
- * @param {string?} operator ['=', '<', '>' ,'!=', '!<', '!>' ,'LIKE']
80
- * @param {any?} value
81
- * @return {this}
82
- */
83
- orWhere(column: string, operator?: any, value?: any): this;
84
- /**
85
- *
86
- * @param {string} sql where column with raw sql
87
- * @return {this} this
88
- */
89
- whereRaw(sql: string): this;
90
- /**
91
- *
92
- * @param {string} query where column with raw sql
93
- * @return {this} this
94
- */
95
- orWhereRaw(sql: string): this;
96
- /**
97
- *
98
- * @param {string} tableAndLocalKey
99
- * @param {string?} tableAndForeignKey
100
- * @return {this}
101
- */
102
- protected whereReference(tableAndLocalKey: string, tableAndForeignKey?: any): this;
103
- /**
104
- *
105
- * where exists
106
- * @param {string} sql
107
- * @return {this}
108
- */
109
- whereExists(sql: string): this;
110
- /**
111
- *
112
- * @param {number} id
113
- * @param {string?} column custom it *if column is not id
114
- * @return {this} this
115
- */
116
- whereId(id: number, column?: string): this;
117
- /**
118
- *
119
- * @param {string} email where using email
120
- * @return {this}
121
- */
122
- whereEmail(email: string): this;
123
- /**
124
- *
125
- * @param {number} id
126
- * @param {string?} column custom it *if column is not user_id
127
- * @return {this}
128
- */
129
- whereUser(id: number, column?: string): this;
130
- /**
131
- * using array value where in value in array
132
- * @param {string} column
133
- * @param {array} array
134
- * @return {this}
135
- */
136
- whereIn(column: string, array: Array<any>): this;
137
- /**
138
- * or where in data using array values
139
- * @param {string} column
140
- * @param {array} array
141
- * @return {this}
142
- */
143
- orWhereIn(column: string, array: Array<any>): this;
144
- /**
145
- * where not in data using array values
146
- * @param {string} column
147
- * @param {array} array
148
- * @return {this}
149
- */
150
- whereNotIn(column: string, array: Array<any>): this;
151
- /**
152
- * where sub query using sub query sql
153
- * @param {string} column
154
- * @param {string} subQuery
155
- * @return {this}
156
- */
157
- whereSubQuery(column: string, subQuery: string): this;
158
- /**
159
- * where not sub query using sub query sql
160
- * @param {string} column
161
- * @param {string} subQuery
162
- * @return {this}
163
- */
164
- whereNotSubQuery(column: string, subQuery: string): this;
165
- /**
166
- * or where not sub query using query sql
167
- * @param {string} column
168
- * @param {string} subQuery
169
- * @return {this}
170
- */
171
- orWhereSubQuery(column: string, subQuery: string): this;
172
- /**
173
- * where between using [value1, value2]
174
- * @param {string} column
175
- * @param {array} array
176
- * @return {this}
177
- */
178
- whereBetween(column: string, array: Array<any>): this;
179
- /**
180
- * where null using NULL
181
- * @param {string} column
182
- * @return {this}
183
- */
184
- whereNull(column: string): this;
185
- /**
186
- * where not null using NULL
187
- * @param {string} column
188
- * @return {this}
189
- */
190
- whereNotNull(column: string): this;
191
- /**
192
- * where sensitive (uppercase, lowercase)
193
- * @param {string} column
194
- * @param {string?} operator = < > != !< !>
195
- * @param {any?} value
196
- * @return {this}
197
- */
198
- whereSensitive(column: string, operator?: any, value?: any): this;
199
- /**
200
- * where group query
201
- * @param {function} callback callback query
202
- * @return {this}
203
- */
204
- whereQuery(callback: Function): this;
205
- /**
206
- * select by cases
207
- * @param {array} cases array object [{ when : 'id < 7' , then : 'id is than under 7'}]
208
- * @param {string} as
209
- * @return {this}
210
- */
211
- case(cases: string | any[], as: string): this;
212
- /**
213
- *
214
- * @param {string} condition
215
- * @return {this}
216
- */
217
- having(condition: string): this;
218
- /**
219
- *
220
- * @param {string} pk talbe.pk
221
- * @param {string} fk talbe.fk
222
- * @return {this}
223
- */
224
- join(pk: string, fk: string): this;
225
- /**
226
- *
227
- * @param {string} pk talbe.pk
228
- * @param {string} fk talbe.fk
229
- * @return {this}
230
- */
231
- rightJoin(pk: string, fk: string): this;
232
- /**
233
- *
234
- * @param {string} pk talbe.pk
235
- * @param {string} fk talbe.fk
236
- * @return {this}
237
- */
238
- leftJoin(pk: string, fk: string): this;
239
- /**
240
- *
241
- * @param {string} pk talbe.pk
242
- * @param {string} fk talbe.fk
243
- * @return {this}
244
- */
245
- crossJoin(pk: string, fk: string): this;
246
- /**
247
- *
248
- * @param {string} column
249
- * @param {string?} order [order=asc] asc, desc
250
- * @return {this}
251
- */
252
- orderBy(column: string, order?: string | undefined): this;
253
- /**
254
- *
255
- * @param {string?} column [column=id]
256
- * @return {this}
257
- */
258
- latest(...columns: Array<string>): this;
259
- /**
260
- *
261
- * @param {string?} column [column=id]
262
- * @return {this}
263
- */
264
- oldest(...columns: Array<string>): this;
265
- /**
266
- *
267
- * @param {string?} column [column=id]
268
- * @return {this}
269
- */
270
- groupBy(...columns: Array<string>): this;
271
- /**
272
- *
273
- * @param {number=} number [number=1]
274
- * @return {this}
275
- */
276
- limit(number?: number): this;
277
- /**
278
- *
279
- * @param {number=} number [number=1]
280
- * @return {this}
281
- */
282
- offset(number?: number | undefined): this;
283
- /**
284
- *
285
- * @param {...string} columns
286
- * @return {this} this
287
- */
288
- hidden(...columns: Array<string>): this;
289
- /**
290
- *
291
- * update data in the database
292
- * @param {object} data
293
- * @return {this} this
294
- */
295
- update(data: object): this;
296
- /**
297
- *
298
- * insert data into the database
299
- * @param {object} data
300
- * @return {this} this
301
- */
302
- insert(data: object): this;
303
- /**
304
- *
305
- * insert data into the database
306
- * @param {object} data
307
- * @return {this} this
308
- */
309
- create(data: object): this;
310
- /**
311
- *
312
- * insert muliple data into the database
313
- * @param {array} data create multiple data
314
- * @return {this} this this
315
- */
316
- createMultiple(data: Array<any>): this;
317
- /**
318
- *
319
- * insert muliple data into the database
320
- * @param {array} data create multiple data
321
- * @return {this} this this
322
- */
323
- insertMultiple(data: Array<any>): this;
324
- /**
325
- *
326
- * @return {string} return sql query
327
- */
328
- toString(): string;
329
- /**
330
- *
331
- * @return {string} return sql query
332
- */
333
- toSQL(): string;
334
- /**
335
- *
336
- * @param {boolean} debug debug sql statements
337
- * @return {this} this this
338
- */
339
- debug(debug?: boolean): this;
340
- /**
341
- *
342
- * @param {boolean} debug debug sql statements
343
- * @return {this} this this
344
- */
345
- dd(debug?: boolean): this;
346
- /**
347
- * hook function when execute returned result to callback function
348
- * @param {Function} func function for callback result
349
- * @return {this}
350
- */
351
- hook(func: Function): this;
352
- /**
353
- *
354
- * @param {object} data create not exists data
355
- * @return {this} this this
356
- */
357
- createNotExists(data: object): this;
358
- /**
359
- *
360
- * @param {object} data insert not exists data
361
- * @return {this} this this
362
- */
363
- insertNotExists(data: object): this;
364
- /**
365
- *
366
- * check data if exists if exists then update. if not exists insert
367
- * @param {object} data insert or update data
368
- * @return {this} this this
369
- */
370
- updateOrCreate(data: object): this;
371
- /**
372
- *
373
- * check data if exists if exists then update. if not exists insert
374
- * @param {object} data insert or update data
375
- * @return {this} this this
376
- */
377
- updateOrInsert(data: object): this;
378
- /**
379
- *
380
- * check data if exists if exists then update. if not exists insert
381
- * @param {object} data insert or update data
382
- * @return {this} this this
383
- */
384
- insertOrUpdate(data: object): this;
385
- /**
386
- *
387
- * check data if exists if exists then update. if not exists insert
388
- * @param {object} data create or update data
389
- * @return {this} this this
390
- */
391
- createOrUpdate(data: object): this;
392
- /**
393
- *
394
- * @param {Object} options options for connection database with credentials
395
- * @param {string} option.host
396
- * @param {number} option.port
397
- * @param {string} option.database
398
- * @param {string} option.user
399
- * @param {string} option.password
400
- * @return {this} this
401
- */
402
- connection(options: ConnectionOptions): this;
403
- /**
404
- *
405
- * @param {Function} pool pool connection database
406
- * @return {this} this
407
- */
408
- pool(pool: Connection): this;
409
- /**
410
- * make sure this connection has same transaction in pool connection
411
- * @param {object} connection pool database
412
- * @return {this} this
413
- */
414
- bind(connection: Connection | ConnectionTransaction): this;
415
- /**
416
- * exceptColumns for method except
417
- * @return {promise<string>} string
418
- */
419
- exceptColumns(): Promise<string>;
420
- /**
421
- * execute sql statements with raw sql query
422
- * @param {string} sql sql execute return data
423
- * @return {promise<any>}
424
- */
425
- rawQuery(sql: string): Promise<any>;
426
- /**
427
- *
428
- * plus value then update
429
- * @param {string} column
430
- * @param {number} value
431
- * @return {promise<any>}
432
- */
433
- increment(column?: string, value?: number): Promise<any>;
434
- /**
435
- *
436
- * minus value then update
437
- * @param {string} column
438
- * @param {number} value
439
- * @return {promise<any>}
440
- */
441
- decrement(column?: string, value?: number): Promise<any>;
442
- /**
443
- * execute data without condition
444
- * @return {promise<any>}
445
- */
446
- all(): Promise<any>;
447
- /**
448
- *
449
- * execute data with where by id
450
- * @param {number} id
451
- * @return {promise<any>}
452
- */
453
- find(id: number): Promise<any>;
454
- /**
455
- *
456
- * execute data page & limit
457
- * @param {?object} paginationOptions
458
- * @param {number} paginationOptions.limit default 15
459
- * @param {number} paginationOptions.page default 1
460
- * @return {promise<Pagination>}
461
- */
462
- pagination(paginationOptions?: {
463
- limit?: number;
464
- page?: number;
465
- }): Promise<Pagination>;
466
- /**
467
- *
468
- * execute data useing page & limit
469
- * @param {?object} paginationOptions
470
- * @param {number} paginationOptions.limit
471
- * @param {number} paginationOptions.page
472
- * @return {promise<Pagination>}
473
- */
474
- paginate(paginationOptions?: {
475
- limit?: number;
476
- page?: number;
477
- }): Promise<Pagination>;
478
- /**
479
- *
480
- * execute data return object | null
481
- * @return {promise<object | null>}
482
- */
483
- first(): Promise<{
484
- [key: string]: any;
485
- } | null>;
486
- /**
487
- *
488
- * execute data return object | throw rror
489
- * @return {promise<object | null>}
490
- */
491
- findOne(): Promise<{
492
- [key: string]: any;
493
- } | null>;
494
- /**
495
- *
496
- * execute data return object | throw Error
497
- * @return {promise<object | Error>}
498
- */
499
- firstOrError(message: string, options?: {
500
- [key: string]: any;
501
- }): Promise<{
502
- [key: string]: any;
503
- }>;
504
- /**
505
- *
506
- * execute data return object | null
507
- * @return {promise<object | null>}
508
- */
509
- findOneOrError(message: string, options?: {
510
- [key: string]: any;
511
- }): Promise<{
512
- [key: string]: any;
513
- }>;
514
- /**
515
- *
516
- * execute data return Array
517
- * @return {promise<Array<any>>}
518
- */
519
- get(): Promise<Array<any>>;
520
- /**
521
- *
522
- * execute data return Array
523
- * @return {promise<Array<any>>}
524
- */
525
- findMany(): Promise<Array<any>>;
526
- /**
527
- *
528
- * execute data return json of result
529
- * @return {promise<string>}
530
- */
531
- toJSON(): Promise<string>;
532
- /**
533
- *
534
- * execute data return array of results
535
- * @param {string=} column [column=id]
536
- * @return {promise<Array>}
537
- */
538
- toArray(column?: string): Promise<Array<any>>;
539
- /**
540
- *
541
- * execute data return number of results
542
- * @param {string=} column [column=id]
543
- * @return {promise<number>}
544
- */
545
- count(column?: string): Promise<number>;
546
- /**
547
- *
548
- * execute data return result is exists
549
- * @return {promise<boolean>}
550
- */
551
- exists(): Promise<boolean>;
552
- /**
553
- *
554
- * execute data return average of results
555
- * @param {string=} column [column=id]
556
- * @return {promise<number>}
557
- */
558
- avg(column?: string): Promise<number>;
559
- /**
560
- *
561
- * execute data return summary of results
562
- * @param {string=} column [column=id]
563
- * @return {promise<number>}
564
- */
565
- sum(column?: string): Promise<number>;
566
- /**
567
- *
568
- * execute data return maximum of results
569
- * @param {string=} column [column=id]
570
- * @return {promise<number>}
571
- */
572
- max(column?: string): Promise<number>;
573
- /**
574
- *
575
- * execute data return minimum of results
576
- * @param {string=} column [column=id]
577
- * @return {promise<number>}
578
- */
579
- min(column?: string): Promise<number>;
580
- /**
581
- *
582
- * delete data from database
583
- * @return {promise<boolean>}
584
- */
585
- delete(): Promise<boolean>;
586
- /**
587
- *
588
- * delete data from database ignore where condition
589
- * @return {promise<boolean>}
590
- */
591
- forceDelete(): Promise<boolean>;
592
- /**
593
- *
594
- * execute data return Array *grouping results in column
595
- * @param {string} column
596
- * @return {promise<Array>}
597
- */
598
- getGroupBy(column: string): Promise<Array<any>>;
599
- /**
600
- *
601
- * execute data return grouping results by index
602
- * @param {string} column
603
- * @return {promise<Array>}
604
- */
605
- findManyGroupBy(column: string): Promise<Array<any>>;
606
- /**
607
- * execute data when save *action [insert , update]
608
- * @return {Promise<any>} promise
609
- */
610
- save(): Promise<{
611
- [key: string]: any;
612
- } | Array<any> | null | undefined>;
613
- /**
614
- *
615
- * show columns in table
616
- * @param {string=} table table name
617
- * @return {Promise<Array>}
618
- */
619
- showColumns(table?: string): Promise<Array<string>>;
620
- /**
621
- *
622
- * show schemas in table
623
- * @param {string=} table [table= current table name]
624
- * @return {Promise<Array>}
625
- */
626
- showSchemas(table?: string): Promise<Array<string>>;
627
- /**
628
- *
629
- * show values in table
630
- * @param {string=} table table name
631
- * @return {Promise<Array>}
632
- */
633
- showValues(table?: string): Promise<Array<string>>;
634
- /**
635
- *
636
- * backup this database intro new database same server or to another server
637
- * @param {Object} backupOptions
638
- * @param {string} backup.database
639
- * @param {object?} backup.to
640
- * @param {string} backup.to.host
641
- * @param {number} backup.to.port
642
- * @param {string} backup.to.database
643
- * @param {string} backup.to.username
644
- * @param {string} backup.to.password
645
-
646
- * @return {Promise<boolean>}
647
- */
648
- backup({ database, to }: Backup): Promise<boolean>;
649
- /**
650
- *
651
- * backup database intro file
652
- * @param {Object} backupOptions
653
- * @param {string} backup.database
654
- * @param {object?} backup.filePath
655
- * @param {object?} backup.connection
656
- * @param {string} backup.connection.host
657
- * @param {number} backup.connection.port
658
- * @param {string} backup.connection.database
659
- * @param {string} backup.connection.username
660
- * @param {string} backup.connection.password
661
-
662
- * @return {Promise<boolean>}
663
- */
664
- backupToFile({ filePath, database, connection }: BackupToFile): Promise<void>;
665
- /**
666
- *
667
- * fake data
668
- * @param {number} rows number of rows
669
- * @return {promise<any>}
670
- */
671
- faker(rows?: number): Promise<any>;
672
- /**
673
- *
674
- * truncate of table
675
- * @return {promise<boolean>}
676
- */
677
- truncate(): Promise<boolean>;
678
- /**
679
- *
680
- * drop of table
681
- * @return {promise<boolean>}
682
- */
683
- drop(): Promise<boolean>;
684
- private _queryWhereIsExists;
685
- private _bindTableAndColumnInQueryWhere;
686
- private _insertNotExists;
687
- protected queryStatement(sql: string): Promise<Array<any>>;
688
- protected actionStatement({ sql, returnId }: {
689
- sql: string;
690
- returnId?: boolean;
691
- }): Promise<any>;
692
- private _create;
693
- private _createMultiple;
694
- private _updateOrInsert;
695
- private _update;
696
- private _hiddenColumn;
697
- private _queryUpdate;
698
- private _queryInsert;
699
- private _queryInsertMultiple;
700
- private _valueAndOperator;
701
- private _valueTrueFalse;
702
- private _buildQuery;
703
- private _initialConnection;
704
- }
705
- export { Database };
706
- export default Database;
1
+ import { AbstractBuilder } from './AbstractBuilder';
2
+ import { Pagination, Backup, ConnectionOptions, BackupToFile, Connection, ConnectionTransaction } from './Interface';
3
+ declare class Builder extends AbstractBuilder {
4
+ constructor();
5
+ /**
6
+ *
7
+ * @param {string} column
8
+ * @return {this}
9
+ */
10
+ pluck(column: string): this;
11
+ /**
12
+ *
13
+ * @param {...string} columns
14
+ * @return {this} this
15
+ */
16
+ except(...columns: Array<string>): this;
17
+ /**
18
+ * data alaways will return void
19
+ * @return {this} this
20
+ */
21
+ void(): this;
22
+ /**
23
+ *
24
+ * @param {...string} columns show only colums selected
25
+ * @return {this} this
26
+ */
27
+ only(...columns: Array<string>): this;
28
+ /**
29
+ *
30
+ * @param {string=} column [column=id]
31
+ * @return {this} this
32
+ */
33
+ distinct(column?: string): this;
34
+ /**
35
+ * select data form table
36
+ * @param {Array<string>} ...columns
37
+ * @return {this} this
38
+ */
39
+ select(...columns: Array<string>): this;
40
+ selectRaw(...columns: Array<string>): this;
41
+ /**
42
+ * chunks data from array
43
+ * @param {number} chunk
44
+ * @return {this} this
45
+ */
46
+ chunk(chunk: number): this;
47
+ /**
48
+ *
49
+ * @param {string | number | undefined | null | Boolean} condition when condition true will return query callback
50
+ * @return {this} this
51
+ */
52
+ when(condition: string | number | undefined | null | Boolean, callback: Function): this;
53
+ /**
54
+ * if has 2 arguments default operator '='
55
+ * @param {string} column
56
+ * @param {string?} operator ['=', '<', '>' ,'!=', '!<', '!>' ,'LIKE']
57
+ * @param {any?} value
58
+ * @return {this}
59
+ */
60
+ resetWhere(): this;
61
+ /**
62
+ * if has 2 arguments default operator '='
63
+ * @param {string} column if arguments is object
64
+ * @param {string?} operator ['=', '<', '>' ,'!=', '!<', '!>' ,'LIKE']
65
+ * @param {any?} value
66
+ * @return {this}
67
+ */
68
+ where(column: string | any, operator?: any, value?: any): this;
69
+ /**
70
+ * where using object operator only '='
71
+ * @param {Object} columns
72
+ * @return {this}
73
+ */
74
+ whereObject(columns: {
75
+ [key: string]: any;
76
+ }): this;
77
+ /**
78
+ * if has 2 arguments default operator '='
79
+ * @param {string} column
80
+ * @param {string?} operator ['=', '<', '>' ,'!=', '!<', '!>' ,'LIKE']
81
+ * @param {any?} value
82
+ * @return {this}
83
+ */
84
+ orWhere(column: string, operator?: any, value?: any): this;
85
+ /**
86
+ *
87
+ * @param {string} sql where column with raw sql
88
+ * @return {this} this
89
+ */
90
+ whereRaw(sql: string): this;
91
+ /**
92
+ *
93
+ * @param {string} query where column with raw sql
94
+ * @return {this} this
95
+ */
96
+ orWhereRaw(sql: string): this;
97
+ /**
98
+ *
99
+ * @param {string} tableAndLocalKey
100
+ * @param {string?} tableAndForeignKey
101
+ * @return {this}
102
+ */
103
+ protected whereReference(tableAndLocalKey: string, tableAndForeignKey?: any): this;
104
+ /**
105
+ *
106
+ * where exists
107
+ * @param {string} sql
108
+ * @return {this}
109
+ */
110
+ whereExists(sql: string): this;
111
+ /**
112
+ *
113
+ * @param {number} id
114
+ * @return {this} this
115
+ */
116
+ whereId(id: number, column?: string): this;
117
+ /**
118
+ *
119
+ * @param {string} email where using email
120
+ * @return {this}
121
+ */
122
+ whereEmail(email: string): this;
123
+ /**
124
+ *
125
+ * @param {number} userId
126
+ * @param {string?} column custom it *if column is not user_id
127
+ * @return {this}
128
+ */
129
+ whereUser(userId: number, column?: string): this;
130
+ /**
131
+ * using array value where in value in array
132
+ * @param {string} column
133
+ * @param {array} array
134
+ * @return {this}
135
+ */
136
+ whereIn(column: string, array: Array<any>): this;
137
+ /**
138
+ * or where in data using array values
139
+ * @param {string} column
140
+ * @param {array} array
141
+ * @return {this}
142
+ */
143
+ orWhereIn(column: string, array: Array<any>): this;
144
+ /**
145
+ * where not in data using array values
146
+ * @param {string} column
147
+ * @param {array} array
148
+ * @return {this}
149
+ */
150
+ whereNotIn(column: string, array: Array<any>): this;
151
+ /**
152
+ * where not in data using array values
153
+ * @param {string} column
154
+ * @param {array} array
155
+ * @return {this}
156
+ */
157
+ orWhereNotIn(column: string, array: Array<any>): this;
158
+ /**
159
+ * where sub query using sub query sql
160
+ * @param {string} column
161
+ * @param {string} subQuery
162
+ * @return {this}
163
+ */
164
+ whereSubQuery(column: string, subQuery: string): this;
165
+ /**
166
+ * where not sub query using sub query sql
167
+ * @param {string} column
168
+ * @param {string} subQuery
169
+ * @return {this}
170
+ */
171
+ whereNotSubQuery(column: string, subQuery: string): this;
172
+ /**
173
+ * or where not sub query using query sql
174
+ * @param {string} column
175
+ * @param {string} subQuery
176
+ * @return {this}
177
+ */
178
+ orWhereSubQuery(column: string, subQuery: string): this;
179
+ /**
180
+ * or where not sub query using query sql
181
+ * @param {string} column
182
+ * @param {string} subQuery
183
+ * @return {this}
184
+ */
185
+ orWhereNotSubQuery(column: string, subQuery: string): this;
186
+ /**
187
+ * where between using [value1, value2]
188
+ * @param {string} column
189
+ * @param {array} array
190
+ * @return {this}
191
+ */
192
+ whereBetween(column: string, array: Array<any>): this;
193
+ /**
194
+ * where null using NULL
195
+ * @param {string} column
196
+ * @return {this}
197
+ */
198
+ whereNull(column: string): this;
199
+ /**
200
+ * where not null using NULL
201
+ * @param {string} column
202
+ * @return {this}
203
+ */
204
+ whereNotNull(column: string): this;
205
+ /**
206
+ * where sensitive (uppercase, lowercase)
207
+ * @param {string} column
208
+ * @param {string?} operator = < > != !< !>
209
+ * @param {any?} value
210
+ * @return {this}
211
+ */
212
+ whereSensitive(column: string, operator?: any, value?: any): this;
213
+ /**
214
+ * where Strict (uppercase, lowercase)
215
+ * @param {string} column
216
+ * @param {string?} operator = < > != !< !>
217
+ * @param {any?} value
218
+ * @return {this}
219
+ */
220
+ whereStrict(column: string, operator?: any, value?: any): this;
221
+ /**
222
+ * where group query
223
+ * @param {function} callback callback query
224
+ * @return {this}
225
+ */
226
+ whereQuery(callback: Function): this;
227
+ /**
228
+ * select by cases
229
+ * @param {array} cases array object [{ when : 'id < 7' , then : 'id is than under 7'}]
230
+ * @param {string} as
231
+ * @return {this}
232
+ */
233
+ case(cases: string | any[], as: string): this;
234
+ /**
235
+ *
236
+ * @param {string} pk talbe.pk
237
+ * @param {string} fk talbe.fk
238
+ * @return {this}
239
+ */
240
+ join(pk: string, fk: string): this;
241
+ /**
242
+ *
243
+ * @param {string} pk talbe.pk
244
+ * @param {string} fk talbe.fk
245
+ * @return {this}
246
+ */
247
+ rightJoin(pk: string, fk: string): this;
248
+ /**
249
+ *
250
+ * @param {string} pk talbe.pk
251
+ * @param {string} fk talbe.fk
252
+ * @return {this}
253
+ */
254
+ leftJoin(pk: string, fk: string): this;
255
+ /**
256
+ *
257
+ * @param {string} pk talbe.pk
258
+ * @param {string} fk talbe.fk
259
+ * @return {this}
260
+ */
261
+ crossJoin(pk: string, fk: string): this;
262
+ /**
263
+ * sort the result in ASC or DESC order.
264
+ * @param {string} column
265
+ * @param {string?} order [order=asc] asc, desc
266
+ * @return {this}
267
+ */
268
+ orderBy(column: string, order?: string | undefined): this;
269
+ /**
270
+ * sort the result in ASC or DESC order. can using with raw query
271
+ * @param {string} column
272
+ * @param {string?} order [order=asc] asc, desc
273
+ * @return {this}
274
+ */
275
+ orderByRaw(column: string, order?: string | undefined): this;
276
+ /**
277
+ * sort the result in using DESC for order by.
278
+ * @param {string?} columns [column=id]
279
+ * @return {this}
280
+ */
281
+ latest(...columns: Array<string>): this;
282
+ /**
283
+ * sort the result in using DESC for order by. can using with raw query
284
+ * @param {string?} columns [column=id]
285
+ * @return {this}
286
+ */
287
+ latestRaw(...columns: Array<string>): this;
288
+ /**
289
+ * sort the result in using ASC for order by.
290
+ * @param {string?} columns [column=id]
291
+ * @return {this}
292
+ */
293
+ oldest(...columns: Array<string>): this;
294
+ /**
295
+ * sort the result in using ASC for order by. can using with raw query
296
+ * @param {string?} columns [column=id]
297
+ * @return {this}
298
+ */
299
+ oldestRaw(...columns: Array<string>): this;
300
+ /**
301
+ *
302
+ * @param {string?} columns [column=id]
303
+ * @return {this}
304
+ */
305
+ groupBy(...columns: Array<string>): this;
306
+ /**
307
+ *
308
+ * @param {string?} columns [column=id]
309
+ * @return {this}
310
+ */
311
+ groupByRaw(...columns: Array<string>): this;
312
+ /**
313
+ *
314
+ * @param {string} condition
315
+ * @return {this}
316
+ */
317
+ having(condition: string): this;
318
+ /**
319
+ *
320
+ * @param {string} condition
321
+ * @return {this}
322
+ */
323
+ havingRaw(condition: string): this;
324
+ /**
325
+ * sort the result in random order.
326
+ * @return {this}
327
+ */
328
+ random(): this;
329
+ /**
330
+ * sort the result in random order.
331
+ * @return {this}
332
+ */
333
+ inRandom(): this;
334
+ /**
335
+ * limit data
336
+ * @param {number=} number [number=1]
337
+ * @return {this}
338
+ */
339
+ limit(number?: number): this;
340
+ /**
341
+ * limit data
342
+ * @param {number=} number [number=1]
343
+ * @return {this}
344
+ */
345
+ take(number?: number): this;
346
+ /**
347
+ *
348
+ * @param {number=} number [number=1]
349
+ * @return {this}
350
+ */
351
+ offset(number?: number): this;
352
+ /**
353
+ *
354
+ * @param {number=} number [number=1]
355
+ * @return {this}
356
+ */
357
+ skip(number?: number): this;
358
+ /**
359
+ *
360
+ * @param {...string} columns
361
+ * @return {this} this
362
+ */
363
+ hidden(...columns: Array<string>): this;
364
+ /**
365
+ *
366
+ * update data in the database
367
+ * @param {object} data
368
+ * @return {this} this
369
+ */
370
+ update(data: {
371
+ [key: string]: any;
372
+ } & {
373
+ length?: unknown;
374
+ }): this;
375
+ /**
376
+ *
377
+ * insert data into the database
378
+ * @param {object} data
379
+ * @return {this} this
380
+ */
381
+ insert(data: {
382
+ [key: string]: any;
383
+ } & {
384
+ length?: unknown;
385
+ }): this;
386
+ /**
387
+ *
388
+ * insert data into the database
389
+ * @param {object} data
390
+ * @return {this} this
391
+ */
392
+ create(data: {
393
+ [key: string]: any;
394
+ } & {
395
+ length?: unknown;
396
+ }): this;
397
+ /**
398
+ *
399
+ * insert muliple data into the database
400
+ * @param {array} data create multiple data
401
+ * @return {this} this this
402
+ */
403
+ createMultiple(data: Array<any>): this;
404
+ /**
405
+ *
406
+ * insert muliple data into the database
407
+ * @param {array} data create multiple data
408
+ * @return {this} this this
409
+ */
410
+ insertMultiple(data: Array<any>): this;
411
+ /**
412
+ *
413
+ * @return {string} return sql query
414
+ */
415
+ toString(): string;
416
+ /**
417
+ *
418
+ * @return {string} return sql query
419
+ */
420
+ toSQL(): string;
421
+ /**
422
+ *
423
+ * @param {boolean} debug debug sql statements
424
+ * @return {this} this this
425
+ */
426
+ debug(debug?: boolean): this;
427
+ /**
428
+ *
429
+ * @param {boolean} debug debug sql statements
430
+ * @return {this} this this
431
+ */
432
+ dd(debug?: boolean): this;
433
+ /**
434
+ * hook function when execute returned result to callback function
435
+ * @param {Function} func function for callback result
436
+ * @return {this}
437
+ */
438
+ hook(func: Function): this;
439
+ /**
440
+ * hook function when execute returned result to callback function
441
+ * @param {Function} func function for callback result
442
+ * @return {this}
443
+ */
444
+ before(func: Function): this;
445
+ /**
446
+ *
447
+ * @param {object} data create not exists data
448
+ * @return {this} this this
449
+ */
450
+ createNotExists(data: {
451
+ [key: string]: any;
452
+ } & {
453
+ length?: unknown;
454
+ }): this;
455
+ /**
456
+ *
457
+ * @param {object} data insert not exists data
458
+ * @return {this} this this
459
+ */
460
+ insertNotExists(data: Record<string, any> & {
461
+ length?: never;
462
+ }): this;
463
+ /**
464
+ *
465
+ * check data if exists if exists then return result. if not exists insert data
466
+ * @param {object} data insert data
467
+ * @return {this} this this
468
+ */
469
+ createOrSelect(data: Record<string, any> & {
470
+ length?: never;
471
+ }): this;
472
+ /**
473
+ *
474
+ * check data if exists if exists then update. if not exists insert
475
+ * @param {object} data insert or update data
476
+ * @return {this} this this
477
+ */
478
+ insertOrSelect(data: Record<string, any> & {
479
+ length?: never;
480
+ }): this;
481
+ /**
482
+ *
483
+ * check data if exists if exists then update. if not exists insert
484
+ * @param {object} data insert or update data
485
+ * @return {this} this this
486
+ */
487
+ updateOrCreate(data: Record<string, any> & {
488
+ length?: never;
489
+ }): this;
490
+ /**
491
+ *
492
+ * check data if exists if exists then update. if not exists insert
493
+ * @param {object} data insert or update data
494
+ * @return {this} this this
495
+ */
496
+ updateOrInsert(data: Record<string, any> & {
497
+ length?: never;
498
+ }): this;
499
+ /**
500
+ *
501
+ * check data if exists if exists then update. if not exists insert
502
+ * @param {object} data insert or update data
503
+ * @return {this} this this
504
+ */
505
+ insertOrUpdate(data: Record<string, any> & {
506
+ length?: never;
507
+ }): this;
508
+ /**
509
+ *
510
+ * check data if exists if exists then update. if not exists insert
511
+ * @param {object} data create or update data
512
+ * @return {this} this this
513
+ */
514
+ createOrUpdate(data: Record<string, any> & {
515
+ length?: never;
516
+ }): this;
517
+ /**
518
+ *
519
+ * @param {Object} options options for connection database with credentials
520
+ * @param {string} option.host
521
+ * @param {number} option.port
522
+ * @param {string} option.database
523
+ * @param {string} option.user
524
+ * @param {string} option.password
525
+ * @return {this} this
526
+ */
527
+ connection(options: ConnectionOptions): this;
528
+ /**
529
+ *
530
+ * @param {Function} pool pool connection database
531
+ * @return {this} this
532
+ */
533
+ pool(pool: Connection): this;
534
+ /**
535
+ * make sure this connection has same transaction in pool connection
536
+ * @param {object} connection pool database
537
+ * @return {this} this
538
+ */
539
+ bind(connection: Connection | ConnectionTransaction): this;
540
+ /**
541
+ * exceptColumns for method except
542
+ * @return {promise<string>} string
543
+ */
544
+ protected exceptColumns(): Promise<string>;
545
+ /**
546
+ * execute sql statements with raw sql query
547
+ * @param {string} sql sql execute return data
548
+ * @return {promise<any>}
549
+ */
550
+ rawQuery(sql: string): Promise<any>;
551
+ /**
552
+ *
553
+ * plus value then update
554
+ * @param {string} column
555
+ * @param {number} value
556
+ * @return {promise<any>}
557
+ */
558
+ increment(column?: string, value?: number): Promise<any>;
559
+ /**
560
+ *
561
+ * minus value then update
562
+ * @param {string} column
563
+ * @param {number} value
564
+ * @return {promise<any>}
565
+ */
566
+ decrement(column?: string, value?: number): Promise<any>;
567
+ /**
568
+ * execute data without condition
569
+ * @return {promise<any>}
570
+ */
571
+ all(): Promise<any>;
572
+ /**
573
+ *
574
+ * execute data with where by primary key default = id
575
+ * @param {number} id
576
+ * @return {promise<any>}
577
+ */
578
+ find(id: number): Promise<Record<string, any> | null>;
579
+ /**
580
+ *
581
+ * execute data page & limit
582
+ * @param {?object} paginationOptions
583
+ * @param {number} paginationOptions.limit default 15
584
+ * @param {number} paginationOptions.page default 1
585
+ * @return {promise<Pagination>}
586
+ */
587
+ pagination(paginationOptions?: {
588
+ limit?: number;
589
+ page?: number;
590
+ }): Promise<Pagination>;
591
+ /**
592
+ *
593
+ * execute data useing page & limit
594
+ * @param {?object} paginationOptions
595
+ * @param {number} paginationOptions.limit
596
+ * @param {number} paginationOptions.page
597
+ * @return {promise<Pagination>}
598
+ */
599
+ paginate(paginationOptions?: {
600
+ limit?: number;
601
+ page?: number;
602
+ }): Promise<Pagination>;
603
+ /**
604
+ *
605
+ * execute data return object | null
606
+ * @return {promise<object | null>}
607
+ */
608
+ first(): Promise<{
609
+ [key: string]: any;
610
+ } | null>;
611
+ /**
612
+ *
613
+ * execute data return object | throw rror
614
+ * @return {promise<object | null>}
615
+ */
616
+ findOne(): Promise<{
617
+ [key: string]: any;
618
+ } | null>;
619
+ /**
620
+ *
621
+ * execute data return object | throw Error
622
+ * @return {promise<object | Error>}
623
+ */
624
+ firstOrError(message: string, options?: {
625
+ [key: string]: any;
626
+ }): Promise<{
627
+ [key: string]: any;
628
+ }>;
629
+ /**
630
+ *
631
+ * execute data return object | null
632
+ * @return {promise<object | null>}
633
+ */
634
+ findOneOrError(message: string, options?: {
635
+ [key: string]: any;
636
+ }): Promise<{
637
+ [key: string]: any;
638
+ }>;
639
+ /**
640
+ *
641
+ * execute data return Array
642
+ * @return {promise<Array<any>>}
643
+ */
644
+ get(): Promise<Array<any>>;
645
+ /**
646
+ *
647
+ * execute data return Array
648
+ * @return {promise<Array<any>>}
649
+ */
650
+ findMany(): Promise<Array<any>>;
651
+ /**
652
+ *
653
+ * execute data return json of result
654
+ * @return {promise<string>}
655
+ */
656
+ toJSON(): Promise<string>;
657
+ /**
658
+ *
659
+ * execute data return array of results
660
+ * @param {string=} column [column=id]
661
+ * @return {promise<Array>}
662
+ */
663
+ toArray(column?: string): Promise<Array<any>>;
664
+ /**
665
+ *
666
+ * execute data return number of results
667
+ * @param {string=} column [column=id]
668
+ * @return {promise<number>}
669
+ */
670
+ count(column?: string): Promise<number>;
671
+ /**
672
+ *
673
+ * execute data return result is exists
674
+ * @return {promise<boolean>}
675
+ */
676
+ exists(): Promise<boolean>;
677
+ /**
678
+ *
679
+ * execute data return average of results
680
+ * @param {string=} column [column=id]
681
+ * @return {promise<number>}
682
+ */
683
+ avg(column?: string): Promise<number>;
684
+ /**
685
+ *
686
+ * execute data return summary of results
687
+ * @param {string=} column [column=id]
688
+ * @return {promise<number>}
689
+ */
690
+ sum(column?: string): Promise<number>;
691
+ /**
692
+ *
693
+ * execute data return maximum of results
694
+ * @param {string=} column [column=id]
695
+ * @return {promise<number>}
696
+ */
697
+ max(column?: string): Promise<number>;
698
+ /**
699
+ *
700
+ * execute data return minimum of results
701
+ * @param {string=} column [column=id]
702
+ * @return {promise<number>}
703
+ */
704
+ min(column?: string): Promise<number>;
705
+ /**
706
+ *
707
+ * delete data from database
708
+ * @return {promise<boolean>}
709
+ */
710
+ delete(): Promise<boolean>;
711
+ /**
712
+ *
713
+ * delete data from database ignore where condition
714
+ * @return {promise<boolean>}
715
+ */
716
+ forceDelete(): Promise<boolean>;
717
+ /**
718
+ *
719
+ * execute data return Array *grouping results in column
720
+ * @param {string} column
721
+ * @return {promise<Array>}
722
+ */
723
+ getGroupBy(column: string): Promise<Array<any>>;
724
+ /**
725
+ *
726
+ * execute data return grouping results by index
727
+ * @param {string} column
728
+ * @return {promise<Array>}
729
+ */
730
+ findManyGroupBy(column: string): Promise<Array<any>>;
731
+ /**
732
+ * execute data when save *action [insert , update]
733
+ * @return {Promise<any>} promise
734
+ */
735
+ save(): Promise<{
736
+ [key: string]: any;
737
+ } | Array<any> | null | undefined>;
738
+ /**
739
+ *
740
+ * show columns in table
741
+ * @param {string=} table table name
742
+ * @return {Promise<Array>}
743
+ */
744
+ showColumns(table?: string): Promise<Array<string>>;
745
+ /**
746
+ *
747
+ * show schemas in table
748
+ * @param {string=} table [table= current table name]
749
+ * @return {Promise<Array>}
750
+ */
751
+ showSchemas(table?: string): Promise<Array<string>>;
752
+ /**
753
+ *
754
+ * show values in table
755
+ * @param {string=} table table name
756
+ * @return {Promise<Array>}
757
+ */
758
+ showValues(table?: string): Promise<Array<string>>;
759
+ /**
760
+ *
761
+ * backup this database intro new database same server or to another server
762
+ * @param {Object} backupOptions
763
+ * @param {string} backup.database
764
+ * @param {object?} backup.to
765
+ * @param {string} backup.to.host
766
+ * @param {number} backup.to.port
767
+ * @param {string} backup.to.database
768
+ * @param {string} backup.to.username
769
+ * @param {string} backup.to.password
770
+
771
+ * @return {Promise<boolean>}
772
+ */
773
+ backup({ database, to }: Backup): Promise<boolean>;
774
+ /**
775
+ *
776
+ * backup database intro file
777
+ * @param {Object} backupOptions
778
+ * @param {string} backup.database
779
+ * @param {object?} backup.filePath
780
+ * @param {object?} backup.connection
781
+ * @param {string} backup.connection.host
782
+ * @param {number} backup.connection.port
783
+ * @param {string} backup.connection.database
784
+ * @param {string} backup.connection.username
785
+ * @param {string} backup.connection.password
786
+
787
+ * @return {Promise<boolean>}
788
+ */
789
+ backupToFile({ filePath, database, connection }: BackupToFile): Promise<void>;
790
+ /**
791
+ *
792
+ * fake data
793
+ * @param {number} rows number of rows
794
+ * @return {promise<any>}
795
+ */
796
+ faker(rows?: number): Promise<any>;
797
+ /**
798
+ *
799
+ * truncate of table
800
+ * @return {promise<boolean>}
801
+ */
802
+ truncate(): Promise<boolean>;
803
+ /**
804
+ *
805
+ * drop of table
806
+ * @return {promise<boolean>}
807
+ */
808
+ drop(): Promise<boolean>;
809
+ private _queryWhereIsExists;
810
+ private _bindTableAndColumnInQueryWhere;
811
+ private _insertNotExists;
812
+ protected queryStatement(sql: string): Promise<Array<any>>;
813
+ protected actionStatement({ sql, returnId }: {
814
+ sql: string;
815
+ returnId?: boolean;
816
+ }): Promise<any>;
817
+ private _insert;
818
+ private _checkValueHasRaw;
819
+ private _insertMultiple;
820
+ private _insertOrSelect;
821
+ private _updateOrInsert;
822
+ private _update;
823
+ private _hiddenColumn;
824
+ private _queryUpdate;
825
+ private _queryInsert;
826
+ private _queryInsertMultiple;
827
+ private _valueAndOperator;
828
+ private _valueTrueFalse;
829
+ private _buildQuery;
830
+ private _initialConnection;
831
+ }
832
+ export { Builder };
833
+ export default Builder;