tspace-mysql 1.1.8 → 1.2.0

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 (36) hide show
  1. package/README.md +115 -38
  2. package/dist/cli/generate/make.d.ts +4 -0
  3. package/dist/cli/generate/make.js +45 -0
  4. package/dist/cli/index.js +27 -13
  5. package/dist/cli/migrate/make.js +5 -4
  6. package/dist/cli/models/make.d.ts +1 -1
  7. package/dist/cli/models/make.js +2 -2
  8. package/dist/cli/models/model.js +3 -4
  9. package/dist/cli/query/index.d.ts +4 -0
  10. package/dist/cli/query/index.js +7 -0
  11. package/dist/lib/connection/index.d.ts +8 -32
  12. package/dist/lib/connection/index.js +50 -37
  13. package/dist/lib/connection/options.d.ts +4 -0
  14. package/dist/lib/{config/env.js → connection/options.js} +10 -7
  15. package/dist/lib/constants/index.d.ts +2 -2
  16. package/dist/lib/constants/index.js +14 -11
  17. package/dist/lib/tspace/AbstractDB.d.ts +2 -0
  18. package/dist/lib/tspace/AbstractDatabase.d.ts +23 -19
  19. package/dist/lib/tspace/AbstractDatabase.js +29 -26
  20. package/dist/lib/tspace/AbstractModel.d.ts +5 -4
  21. package/dist/lib/tspace/Blueprint.js +4 -2
  22. package/dist/lib/tspace/DB.d.ts +23 -2
  23. package/dist/lib/tspace/DB.js +93 -30
  24. package/dist/lib/tspace/Database.d.ts +26 -13
  25. package/dist/lib/tspace/Database.js +920 -777
  26. package/dist/lib/tspace/Interface.d.ts +26 -0
  27. package/dist/lib/tspace/Logger.js +5 -4
  28. package/dist/lib/tspace/Model.d.ts +73 -23
  29. package/dist/lib/tspace/Model.js +1208 -867
  30. package/dist/lib/tspace/ProxyHandler.d.ts +9 -1
  31. package/dist/lib/tspace/ProxyHandler.js +8 -9
  32. package/dist/lib/tspace/Schema.js +35 -22
  33. package/dist/lib/utils/index.d.ts +0 -1
  34. package/dist/lib/utils/index.js +15 -44
  35. package/package.json +4 -2
  36. package/dist/lib/config/env.d.ts +0 -4
@@ -1,6 +1,5 @@
1
1
  import AbstractDatabase from './AbstractDatabase';
2
- import { Connection, ConnectionTransaction } from '../connection';
3
- import { Pagination, Backup, ConnectionOptions, BackupToFile } from './Interface';
2
+ import { Pagination, Backup, ConnectionOptions, BackupToFile, Connection, ConnectionTransaction } from './Interface';
4
3
  declare class Database extends AbstractDatabase {
5
4
  constructor();
6
5
  /**
@@ -16,7 +15,7 @@ declare class Database extends AbstractDatabase {
16
15
  */
17
16
  except(...columns: Array<string>): this;
18
17
  /**
19
- * data will return void
18
+ * data alaways will return void
20
19
  * @return {this} this
21
20
  */
22
21
  void(): this;
@@ -50,6 +49,14 @@ declare class Database extends AbstractDatabase {
50
49
  * @return {this} this
51
50
  */
52
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;
53
60
  /**
54
61
  * if has 2 arguments default operator '='
55
62
  * @param {string} column
@@ -240,19 +247,19 @@ declare class Database extends AbstractDatabase {
240
247
  * @param {string?} column [column=id]
241
248
  * @return {this}
242
249
  */
243
- latest(column?: string): this;
250
+ latest(...columns: Array<string>): this;
244
251
  /**
245
252
  *
246
253
  * @param {string?} column [column=id]
247
254
  * @return {this}
248
255
  */
249
- oldest(column?: string): this;
256
+ oldest(...columns: Array<string>): this;
250
257
  /**
251
258
  *
252
259
  * @param {string?} column [column=id]
253
260
  * @return {this}
254
261
  */
255
- groupBy(column?: string): this;
262
+ groupBy(...columns: Array<string>): this;
256
263
  /**
257
264
  *
258
265
  * @param {number=} number [number=1]
@@ -328,6 +335,12 @@ declare class Database extends AbstractDatabase {
328
335
  * @return {this} this this
329
336
  */
330
337
  dd(debug?: boolean): this;
338
+ /**
339
+ * hook function when execute returned result to callback function
340
+ * @param {Function} func function for callback result
341
+ * @return {this}
342
+ */
343
+ hook(func: Function): this;
331
344
  /**
332
345
  *
333
346
  * @param {object} data create not exists data
@@ -434,8 +447,8 @@ declare class Database extends AbstractDatabase {
434
447
  *
435
448
  * execute data page & limit
436
449
  * @param {?object} paginationOptions
437
- * @param {number} paginationOptions.limit
438
- * @param {number} paginationOptions.page
450
+ * @param {number} paginationOptions.limit default 15
451
+ * @param {number} paginationOptions.page default 1
439
452
  * @return {promise<Pagination>}
440
453
  */
441
454
  pagination(paginationOptions?: {
@@ -586,7 +599,9 @@ declare class Database extends AbstractDatabase {
586
599
  * execute data when save *action [insert , update]
587
600
  * @return {Promise<any>} promise
588
601
  */
589
- save(): Promise<any>;
602
+ save(): Promise<{
603
+ [key: string]: any;
604
+ } | Array<any> | null | undefined>;
590
605
  /**
591
606
  *
592
607
  * show columns in table
@@ -643,7 +658,7 @@ declare class Database extends AbstractDatabase {
643
658
  *
644
659
  * fake data
645
660
  * @param {number} rows number of rows
646
- * @return {promise<any}
661
+ * @return {promise<any>}
647
662
  */
648
663
  faker(rows?: number): Promise<any>;
649
664
  /**
@@ -661,8 +676,7 @@ declare class Database extends AbstractDatabase {
661
676
  private _queryWhereIsExists;
662
677
  private _bindTableAndColumnInQueryWhere;
663
678
  private _insertNotExists;
664
- private _setupPool;
665
- protected queryStatement(sql: string): Promise<any>;
679
+ protected queryStatement(sql: string): Promise<Array<any>>;
666
680
  protected actionStatement({ sql, returnId }: {
667
681
  sql: string;
668
682
  returnId?: boolean;
@@ -678,7 +692,6 @@ declare class Database extends AbstractDatabase {
678
692
  private _valueAndOperator;
679
693
  private _valueTrueFalse;
680
694
  private _buildQuery;
681
- private _setupLogger;
682
695
  private _initialConnection;
683
696
  }
684
697
  export { Database };