tspace-mysql 1.8.2 → 1.8.4

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 (83) hide show
  1. package/README.md +443 -68
  2. package/build/cli/generate/model.js +3 -3
  3. package/build/cli/generate/model.js.map +1 -1
  4. package/build/lib/constants/index.d.ts +7 -1
  5. package/build/lib/constants/index.js +7 -1
  6. package/build/lib/constants/index.js.map +1 -1
  7. package/build/lib/core/Abstracts/AbstractBuilder.d.ts +1 -1
  8. package/build/lib/core/Abstracts/AbstractBuilder.js.map +1 -1
  9. package/build/lib/core/Abstracts/AbstractDB.d.ts +2 -2
  10. package/build/lib/core/Abstracts/AbstractDB.js.map +1 -1
  11. package/build/lib/core/Abstracts/AbstractView.d.ts +10 -0
  12. package/build/lib/core/Abstracts/AbstractView.js +9 -0
  13. package/build/lib/core/Abstracts/AbstractView.js.map +1 -0
  14. package/build/lib/core/Blueprint.d.ts +24 -4
  15. package/build/lib/core/Blueprint.js +78 -87
  16. package/build/lib/core/Blueprint.js.map +1 -1
  17. package/build/lib/core/Builder.d.ts +39 -30
  18. package/build/lib/core/Builder.js +1094 -1044
  19. package/build/lib/core/Builder.js.map +1 -1
  20. package/build/lib/core/Cache/DBCache.js +15 -16
  21. package/build/lib/core/Cache/DBCache.js.map +1 -1
  22. package/build/lib/core/DB.d.ts +38 -38
  23. package/build/lib/core/DB.js +119 -115
  24. package/build/lib/core/DB.js.map +1 -1
  25. package/build/lib/core/Decorator.d.ts +1 -1
  26. package/build/lib/core/Decorator.js.map +1 -1
  27. package/build/lib/core/Handlers/Relation.d.ts +2 -1
  28. package/build/lib/core/Handlers/Relation.js +60 -15
  29. package/build/lib/core/Handlers/Relation.js.map +1 -1
  30. package/build/lib/core/Handlers/State.d.ts +1 -0
  31. package/build/lib/core/Handlers/State.js +1 -1
  32. package/build/lib/core/Handlers/State.js.map +1 -1
  33. package/build/lib/core/JoinModel.d.ts +1 -1
  34. package/build/lib/core/JoinModel.js.map +1 -1
  35. package/build/lib/core/Meta.d.ts +55 -0
  36. package/build/lib/core/Meta.js +175 -0
  37. package/build/lib/core/Meta.js.map +1 -0
  38. package/build/lib/core/Model.d.ts +158 -94
  39. package/build/lib/core/Model.js +1586 -1203
  40. package/build/lib/core/Model.js.map +1 -1
  41. package/build/lib/core/Nest/index.d.ts +3 -1
  42. package/build/lib/core/Nest/index.js +4 -2
  43. package/build/lib/core/Nest/index.js.map +1 -1
  44. package/build/lib/{connection/index.d.ts → core/Pool.d.ts} +2 -1
  45. package/build/lib/{connection/index.js → core/Pool.js} +74 -6
  46. package/build/lib/core/Pool.js.map +1 -0
  47. package/build/lib/core/Repository.d.ts +16 -16
  48. package/build/lib/core/Repository.js +73 -45
  49. package/build/lib/core/Repository.js.map +1 -1
  50. package/build/lib/core/Schema.d.ts +2 -2
  51. package/build/lib/core/Schema.js +113 -78
  52. package/build/lib/core/Schema.js.map +1 -1
  53. package/build/lib/core/SqlLike.js.map +1 -1
  54. package/build/lib/core/StoredProcedure.d.ts +120 -0
  55. package/build/lib/core/StoredProcedure.js +161 -0
  56. package/build/lib/core/StoredProcedure.js.map +1 -0
  57. package/build/lib/core/UtilityTypes.d.ts +25 -44
  58. package/build/lib/core/View.d.ts +96 -0
  59. package/build/lib/core/View.js +141 -0
  60. package/build/lib/core/View.js.map +1 -0
  61. package/build/lib/core/index.d.ts +17 -12
  62. package/build/lib/core/index.js +9 -4
  63. package/build/lib/core/index.js.map +1 -1
  64. package/build/lib/types/index.d.ts +23 -3
  65. package/build/lib/utils/index.js +5 -2
  66. package/build/lib/utils/index.js.map +1 -1
  67. package/build/tests/01-Pool.test.js +0 -10
  68. package/build/tests/01-Pool.test.js.map +1 -1
  69. package/build/tests/04-Model-pattern.test.js +1 -1
  70. package/build/tests/04-Model-pattern.test.js.map +1 -1
  71. package/build/tests/05-View.test.d.ts +1 -0
  72. package/build/tests/05-View.test.js +83 -0
  73. package/build/tests/05-View.test.js.map +1 -0
  74. package/build/tests/06-Meta.test.d.ts +1 -0
  75. package/build/tests/06-Meta.test.js +103 -0
  76. package/build/tests/06-Meta.test.js.map +1 -0
  77. package/build/tests/07-Virtual-column.test.d.ts +1 -0
  78. package/build/tests/07-Virtual-column.test.js +160 -0
  79. package/build/tests/07-Virtual-column.test.js.map +1 -0
  80. package/build/tests/schema-spec.js +25 -25
  81. package/build/tests/schema-spec.js.map +1 -1
  82. package/package.json +1 -1
  83. package/build/lib/connection/index.js.map +0 -1
@@ -1,6 +1,7 @@
1
- import { AbstractBuilder } from './Abstracts/AbstractBuilder';
2
- import { Join } from './Join';
3
- import { TPagination, TConnectionOptions, TConnection, TConnectionTransaction } from '../types';
1
+ import { AbstractBuilder } from "./Abstracts/AbstractBuilder";
2
+ import { Join } from "./Join";
3
+ import { CONSTANTS } from "../constants";
4
+ import { TPagination, TConnectionOptions, TConnection, TConnectionTransaction } from "../types";
4
5
  declare class Builder extends AbstractBuilder {
5
6
  constructor();
6
7
  /**
@@ -145,7 +146,7 @@ declare class Builder extends AbstractBuilder {
145
146
  * @param {string} type - The types 'object' | 'array'
146
147
  * @returns {this} this
147
148
  */
148
- returnType(type: 'object' | 'array'): this;
149
+ returnType(type: "object" | "array"): this;
149
150
  /**
150
151
  * The 'pluck' method is used to retrieve the value of a single column from the first result of a query.
151
152
  *
@@ -394,7 +395,9 @@ declare class Builder extends AbstractBuilder {
394
395
  * @param {string} subQuery
395
396
  * @returns {this}
396
397
  */
397
- whereSubQuery(column: string, subQuery: string): this;
398
+ whereSubQuery(column: string, subQuery: string, options?: {
399
+ operator?: typeof CONSTANTS['EQ'] | typeof CONSTANTS['IN'];
400
+ }): this;
398
401
  /**
399
402
  * The 'whereNotSubQuery' method is used to add a conditional clause to a database query that involves a subquery.
400
403
  *
@@ -405,7 +408,9 @@ declare class Builder extends AbstractBuilder {
405
408
  * @param {string} subQuery
406
409
  * @returns {this}
407
410
  */
408
- whereNotSubQuery(column: string, subQuery: string): this;
411
+ whereNotSubQuery(column: string, subQuery: string, options?: {
412
+ operator?: typeof CONSTANTS['NOT_EQ'] | typeof CONSTANTS['NOT_IN'];
413
+ }): this;
409
414
  /**
410
415
  * The 'orWhereSubQuery' method is used to add a conditional clause to a database query that involves a subquery.
411
416
  *
@@ -416,7 +421,9 @@ declare class Builder extends AbstractBuilder {
416
421
  * @param {string} subQuery
417
422
  * @returns {this}
418
423
  */
419
- orWhereSubQuery(column: string, subQuery: string): this;
424
+ orWhereSubQuery(column: string, subQuery: string, options?: {
425
+ operator?: typeof CONSTANTS['EQ'] | typeof CONSTANTS['IN'];
426
+ }): this;
420
427
  /**
421
428
  * The 'orWhereNotSubQuery' method is used to add a conditional clause to a database query that involves a subquery.
422
429
  *
@@ -427,7 +434,9 @@ declare class Builder extends AbstractBuilder {
427
434
  * @param {string} subQuery
428
435
  * @returns {this}
429
436
  */
430
- orWhereNotSubQuery(column: string, subQuery: string): this;
437
+ orWhereNotSubQuery(column: string, subQuery: string, options?: {
438
+ operator?: typeof CONSTANTS['NOT_EQ'] | typeof CONSTANTS['NOT_IN'];
439
+ }): this;
431
440
  /**
432
441
  * The 'whereBetween' method is used to add a conditional clause to a database query that checks if a specified column's value falls within a specified range of values.
433
442
  *
@@ -685,7 +694,7 @@ declare class Builder extends AbstractBuilder {
685
694
  * .get()
686
695
  * @returns {this}
687
696
  */
688
- joinSubQuery({ localKey, foreignKey, sql }: {
697
+ joinSubQuery({ localKey, foreignKey, sql, }: {
689
698
  localKey: string;
690
699
  foreignKey: string;
691
700
  sql: string;
@@ -698,7 +707,7 @@ declare class Builder extends AbstractBuilder {
698
707
  * @param {string?} order by default order = 'asc' but you can used 'asc' or 'desc'
699
708
  * @returns {this}
700
709
  */
701
- orderBy(column: string, order?: 'ASC' | 'asc' | 'DESC' | 'desc'): this;
710
+ orderBy(column: string, order?: "ASC" | "asc" | "DESC" | "desc"): this;
702
711
  /**
703
712
  * The 'orderByRaw' method is used to specify the order in which the results of a database query should be sorted.
704
713
  *
@@ -709,7 +718,7 @@ declare class Builder extends AbstractBuilder {
709
718
  * @param {string?} order [order=asc] asc, desc
710
719
  * @returns {this}
711
720
  */
712
- orderByRaw(column: string, order?: 'ASC' | 'asc' | 'DESC' | 'desc'): this;
721
+ orderByRaw(column: string, order?: "ASC" | "asc" | "DESC" | "desc"): this;
713
722
  /**
714
723
  * The 'random' method is used to retrieve random records from a database table or to randomize the order in which records are returned in the query result set.
715
724
  *
@@ -1027,7 +1036,7 @@ declare class Builder extends AbstractBuilder {
1027
1036
  *
1028
1037
  * This method is particularly useful for debugging and understanding the SQL queries generated by your application.
1029
1038
  * @returns {string}
1030
- */
1039
+ */
1031
1040
  toRawSQL(): string;
1032
1041
  /**
1033
1042
  * The 'getTableName' method is used to get table name
@@ -1066,13 +1075,13 @@ declare class Builder extends AbstractBuilder {
1066
1075
  * The 'hook' method is used function when execute returns a result to callback function
1067
1076
  * @param {Function} func function for callback result
1068
1077
  * @returns {this}
1069
- */
1078
+ */
1070
1079
  hook(func: Function): this;
1071
1080
  /**
1072
1081
  * The 'before' method is used function when execute returns a result to callback function
1073
1082
  * @param {Function} func function for callback result
1074
1083
  * @returns {this}
1075
- */
1084
+ */
1076
1085
  before(func: Function): this;
1077
1086
  /**
1078
1087
  *
@@ -1338,20 +1347,20 @@ declare class Builder extends AbstractBuilder {
1338
1347
  */
1339
1348
  getGroupBy(column: string): Promise<Map<string | number, any[]>>;
1340
1349
  /**
1341
- * The 'findGroupBy' method is used to execute a database query and retrieve the result set that matches the query conditions.
1342
- *
1343
- * It retrieves multiple records from a database table based on the criteria specified in the query.
1344
- *
1345
- * It returns record to new Map
1346
- * @param {string} column
1347
- * @example
1348
- * const results = await new DB('posts')
1349
- * .findGroupBy('user_id')
1350
- *
1351
- * // you can find with user id in the results
1352
- * const postsByUserId1 = results.get(1)
1353
- * @returns {promise<Array>}
1354
- */
1350
+ * The 'findGroupBy' method is used to execute a database query and retrieve the result set that matches the query conditions.
1351
+ *
1352
+ * It retrieves multiple records from a database table based on the criteria specified in the query.
1353
+ *
1354
+ * It returns record to new Map
1355
+ * @param {string} column
1356
+ * @example
1357
+ * const results = await new DB('posts')
1358
+ * .findGroupBy('user_id')
1359
+ *
1360
+ * // you can find with user id in the results
1361
+ * const postsByUserId1 = results.get(1)
1362
+ * @returns {promise<Array>}
1363
+ */
1355
1364
  findGroupBy(column: string): Promise<Map<string | number, any[]>>;
1356
1365
  /**
1357
1366
  * The 'save' method is used to persist a new 'Model' or new 'DB' instance or update an existing model instance in the database.
@@ -1444,7 +1453,7 @@ declare class Builder extends AbstractBuilder {
1444
1453
  * @property {boolean} option.force
1445
1454
  * @returns {promise<boolean>}
1446
1455
  */
1447
- truncate({ force }?: {
1456
+ truncate({ force, }?: {
1448
1457
  force?: boolean;
1449
1458
  }): Promise<boolean>;
1450
1459
  /**
@@ -1493,7 +1502,7 @@ declare class Builder extends AbstractBuilder {
1493
1502
  protected _resultHandlerExists(data: any): any;
1494
1503
  whereReference(tableAndLocalKey: string, tableAndForeignKey?: string): this;
1495
1504
  protected _queryStatement(sql: string): Promise<any[]>;
1496
- protected _actionStatement({ sql, returnId }: {
1505
+ protected _actionStatement({ sql, returnId, }: {
1497
1506
  sql: string;
1498
1507
  returnId?: boolean;
1499
1508
  }): Promise<any>;