@riao/dbal 1.1.3 → 3.0.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 (123) hide show
  1. package/README.md +5 -1
  2. package/builder/builder.d.ts +1 -46
  3. package/builder/builder.js +1 -125
  4. package/builder/builder.js.map +1 -1
  5. package/builder/index.d.ts +1 -0
  6. package/builder/index.js +3 -1
  7. package/builder/index.js.map +1 -1
  8. package/builder/sql-builder.d.ts +40 -0
  9. package/builder/sql-builder.js +114 -0
  10. package/builder/sql-builder.js.map +1 -0
  11. package/builder/statement-builder.d.ts +10 -0
  12. package/builder/statement-builder.js +24 -0
  13. package/builder/statement-builder.js.map +1 -0
  14. package/column/column-options.d.ts +1 -1
  15. package/comparison/comparison-aliases.d.ts +10 -0
  16. package/comparison/comparison-aliases.js +41 -0
  17. package/comparison/comparison-aliases.js.map +1 -0
  18. package/comparison/comparison-token.d.ts +17 -0
  19. package/comparison/comparison-token.js +16 -0
  20. package/comparison/comparison-token.js.map +1 -0
  21. package/comparison/comparison.d.ts +13 -0
  22. package/comparison/comparison.js +72 -0
  23. package/comparison/comparison.js.map +1 -0
  24. package/comparison/index.d.ts +4 -0
  25. package/comparison/index.js +25 -0
  26. package/comparison/index.js.map +1 -0
  27. package/comparison/is-comparison-token.d.ts +2 -0
  28. package/comparison/is-comparison-token.js +9 -0
  29. package/comparison/is-comparison-token.js.map +1 -0
  30. package/database/database.d.ts +0 -6
  31. package/database/database.js +1 -8
  32. package/database/database.js.map +1 -1
  33. package/ddl/ddl-builder.d.ts +7 -2
  34. package/ddl/ddl-builder.js +105 -91
  35. package/ddl/ddl-builder.js.map +1 -1
  36. package/ddl/ddl-repository.js +15 -14
  37. package/ddl/ddl-repository.js.map +1 -1
  38. package/dml/delete.d.ts +2 -2
  39. package/dml/group-by.d.ts +4 -0
  40. package/dml/group-by.js +3 -0
  41. package/dml/group-by.js.map +1 -0
  42. package/dml/index.d.ts +2 -2
  43. package/dml/index.js +2 -2
  44. package/dml/index.js.map +1 -1
  45. package/dml/insert.d.ts +7 -4
  46. package/dml/join.d.ts +3 -3
  47. package/dml/query-builder.d.ts +41 -20
  48. package/dml/query-builder.js +301 -172
  49. package/dml/query-builder.js.map +1 -1
  50. package/dml/query-repository.d.ts +7 -1
  51. package/dml/query-repository.js +66 -13
  52. package/dml/query-repository.js.map +1 -1
  53. package/dml/select.d.ts +9 -6
  54. package/dml/subquery.d.ts +5 -0
  55. package/dml/subquery.js +11 -0
  56. package/dml/subquery.js.map +1 -0
  57. package/dml/update.d.ts +2 -2
  58. package/expression/expression-token.d.ts +9 -0
  59. package/expression/expression-token.js +11 -0
  60. package/expression/expression-token.js.map +1 -0
  61. package/expression/expression.d.ts +6 -0
  62. package/expression/expression.js +3 -0
  63. package/expression/expression.js.map +1 -0
  64. package/expression/identifier.d.ts +7 -0
  65. package/expression/identifier.js +16 -0
  66. package/expression/identifier.js.map +1 -0
  67. package/expression/index.d.ts +5 -0
  68. package/expression/index.js +24 -0
  69. package/expression/index.js.map +1 -0
  70. package/expression/is-expression-token.d.ts +2 -0
  71. package/expression/is-expression-token.js +8 -0
  72. package/expression/is-expression-token.js.map +1 -0
  73. package/expression/key-val-expression.d.ts +7 -0
  74. package/expression/key-val-expression.js +3 -0
  75. package/expression/key-val-expression.js.map +1 -0
  76. package/expression/literal.d.ts +2 -0
  77. package/expression/literal.js +3 -0
  78. package/expression/literal.js.map +1 -0
  79. package/expression/logical.d.ts +18 -0
  80. package/expression/logical.js +31 -0
  81. package/expression/logical.js.map +1 -0
  82. package/expression/simple-expression.d.ts +5 -0
  83. package/expression/simple-expression.js +3 -0
  84. package/expression/simple-expression.js.map +1 -0
  85. package/functions/function-aliases.d.ts +3 -0
  86. package/functions/function-aliases.js +13 -0
  87. package/functions/function-aliases.js.map +1 -0
  88. package/functions/{function-interface.d.ts → function-token.d.ts} +8 -7
  89. package/functions/{function-interface.js → function-token.js} +3 -2
  90. package/functions/function-token.js.map +1 -0
  91. package/functions/functions.d.ts +3 -2
  92. package/functions/functions.js +15 -4
  93. package/functions/functions.js.map +1 -1
  94. package/functions/index.d.ts +4 -1
  95. package/functions/index.js +6 -1
  96. package/functions/index.js.map +1 -1
  97. package/functions/is-database-function.d.ts +8 -0
  98. package/functions/is-database-function.js +15 -0
  99. package/functions/is-database-function.js.map +1 -0
  100. package/index.d.ts +4 -0
  101. package/index.js +4 -0
  102. package/index.js.map +1 -1
  103. package/migration/create-migration-table.js +2 -1
  104. package/migration/create-migration-table.js.map +1 -1
  105. package/package.json +1 -1
  106. package/repository/repository-options.d.ts +0 -2
  107. package/repository/repository.d.ts +12 -3
  108. package/repository/repository.js +32 -1
  109. package/repository/repository.js.map +1 -1
  110. package/seed/auto-seed.js +16 -16
  111. package/seed/auto-seed.js.map +1 -1
  112. package/seed/create-seed-table.js +2 -1
  113. package/seed/create-seed-table.js.map +1 -1
  114. package/tokens/index.d.ts +1 -0
  115. package/tokens/index.js +6 -0
  116. package/tokens/index.js.map +1 -0
  117. package/dml/column-name.d.ts +0 -3
  118. package/dml/column-name.js +0 -12
  119. package/dml/column-name.js.map +0 -1
  120. package/dml/where.d.ts +0 -26
  121. package/dml/where.js +0 -67
  122. package/dml/where.js.map +0 -1
  123. package/functions/function-interface.js.map +0 -1
@@ -23,6 +23,7 @@ class DataDefinitionRepository extends repository_1.Repository {
23
23
  }
24
24
  init(options) {
25
25
  super.init(options);
26
+ this.isReady = true;
26
27
  }
27
28
  getDDLBuilder() {
28
29
  return new this.ddlBuilderType();
@@ -34,7 +35,7 @@ class DataDefinitionRepository extends repository_1.Repository {
34
35
  */
35
36
  createDatabase(options) {
36
37
  return __awaiter(this, void 0, void 0, function* () {
37
- yield this.driver.query(this.getDDLBuilder().createDatabase(options));
38
+ yield this.query(this.getDDLBuilder().createDatabase(options));
38
39
  });
39
40
  }
40
41
  /**
@@ -44,7 +45,7 @@ class DataDefinitionRepository extends repository_1.Repository {
44
45
  */
45
46
  createTable(options) {
46
47
  return __awaiter(this, void 0, void 0, function* () {
47
- yield this.driver.query(this.getDDLBuilder().createTable(options));
48
+ yield this.query(this.getDDLBuilder().createTable(options));
48
49
  });
49
50
  }
50
51
  /**
@@ -54,7 +55,7 @@ class DataDefinitionRepository extends repository_1.Repository {
54
55
  */
55
56
  createUser(options) {
56
57
  return __awaiter(this, void 0, void 0, function* () {
57
- yield this.driver.query(this.getDDLBuilder().createUser(options));
58
+ yield this.query(this.getDDLBuilder().createUser(options));
58
59
  });
59
60
  }
60
61
  /**
@@ -71,7 +72,7 @@ class DataDefinitionRepository extends repository_1.Repository {
71
72
  */
72
73
  grant(options) {
73
74
  return __awaiter(this, void 0, void 0, function* () {
74
- yield this.driver.query(this.getDDLBuilder().grant(options));
75
+ yield this.query(this.getDDLBuilder().grant(options));
75
76
  });
76
77
  }
77
78
  /**
@@ -81,7 +82,7 @@ class DataDefinitionRepository extends repository_1.Repository {
81
82
  */
82
83
  addColumns(options) {
83
84
  return __awaiter(this, void 0, void 0, function* () {
84
- yield this.driver.query(this.getDDLBuilder().addColumns(options));
85
+ yield this.query(this.getDDLBuilder().addColumns(options));
85
86
  });
86
87
  }
87
88
  /**
@@ -91,7 +92,7 @@ class DataDefinitionRepository extends repository_1.Repository {
91
92
  */
92
93
  addForeignKey(options) {
93
94
  return __awaiter(this, void 0, void 0, function* () {
94
- yield this.driver.query(this.getDDLBuilder().addForeignKey(options));
95
+ yield this.query(this.getDDLBuilder().addForeignKey(options));
95
96
  });
96
97
  }
97
98
  /**
@@ -101,7 +102,7 @@ class DataDefinitionRepository extends repository_1.Repository {
101
102
  */
102
103
  changeColumn(options) {
103
104
  return __awaiter(this, void 0, void 0, function* () {
104
- yield this.driver.query(this.getDDLBuilder().changeColumn(options));
105
+ yield this.query(this.getDDLBuilder().changeColumn(options));
105
106
  });
106
107
  }
107
108
  /**
@@ -111,7 +112,7 @@ class DataDefinitionRepository extends repository_1.Repository {
111
112
  */
112
113
  dropColumn(options) {
113
114
  return __awaiter(this, void 0, void 0, function* () {
114
- yield this.driver.query(this.getDDLBuilder().dropColumn(options));
115
+ yield this.query(this.getDDLBuilder().dropColumn(options));
115
116
  });
116
117
  }
117
118
  /**
@@ -121,7 +122,7 @@ class DataDefinitionRepository extends repository_1.Repository {
121
122
  */
122
123
  dropForeignKey(options) {
123
124
  return __awaiter(this, void 0, void 0, function* () {
124
- yield this.driver.query(this.getDDLBuilder().dropForeignKey(options));
125
+ yield this.query(this.getDDLBuilder().dropForeignKey(options));
125
126
  });
126
127
  }
127
128
  /**
@@ -131,7 +132,7 @@ class DataDefinitionRepository extends repository_1.Repository {
131
132
  */
132
133
  renameTable(options) {
133
134
  return __awaiter(this, void 0, void 0, function* () {
134
- yield this.driver.query(this.getDDLBuilder().renameTable(options));
135
+ yield this.query(this.getDDLBuilder().renameTable(options));
135
136
  });
136
137
  }
137
138
  /**
@@ -141,7 +142,7 @@ class DataDefinitionRepository extends repository_1.Repository {
141
142
  */
142
143
  dropDatabase(options) {
143
144
  return __awaiter(this, void 0, void 0, function* () {
144
- yield this.driver.query(this.getDDLBuilder().dropDatabase(options));
145
+ yield this.query(this.getDDLBuilder().dropDatabase(options));
145
146
  });
146
147
  }
147
148
  /**
@@ -151,7 +152,7 @@ class DataDefinitionRepository extends repository_1.Repository {
151
152
  */
152
153
  dropTable(options) {
153
154
  return __awaiter(this, void 0, void 0, function* () {
154
- yield this.driver.query(this.getDDLBuilder().dropTable(options));
155
+ yield this.query(this.getDDLBuilder().dropTable(options));
155
156
  });
156
157
  }
157
158
  /**
@@ -161,7 +162,7 @@ class DataDefinitionRepository extends repository_1.Repository {
161
162
  */
162
163
  dropUser(options) {
163
164
  return __awaiter(this, void 0, void 0, function* () {
164
- yield this.driver.query(this.getDDLBuilder().dropUser(options));
165
+ yield this.query(this.getDDLBuilder().dropUser(options));
165
166
  });
166
167
  }
167
168
  /**
@@ -171,7 +172,7 @@ class DataDefinitionRepository extends repository_1.Repository {
171
172
  */
172
173
  truncate(options) {
173
174
  return __awaiter(this, void 0, void 0, function* () {
174
- yield this.driver.query(this.getDDLBuilder().truncate(options));
175
+ yield this.query(this.getDDLBuilder().truncate(options));
175
176
  });
176
177
  }
177
178
  }
@@ -1 +1 @@
1
- {"version":3,"file":"ddl-repository.js","sourceRoot":"","sources":["../../../src/ddl/ddl-repository.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,gCAgBgB;AAEhB,8CAA8E;AAQ9E;;GAEG;AACH,MAAa,wBAAyB,SAAQ,uBAAU;IAIvD,YAAmB,OAA6B;QAC/C,KAAK,CAAC,OAAO,CAAC,CAAC;QAJN,mBAAc,GACvB,2BAAqB,CAAC;QAKtB,IAAI,CAAC,cAAc,GAAG,OAAO,CAAC,cAAc,CAAC;IAC9C,CAAC;IAEM,IAAI,CAAC,OAA0B;QACrC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IACrB,CAAC;IAEM,aAAa;QACnB,OAAO,IAAI,IAAI,CAAC,cAAc,EAAE,CAAC;IAClC,CAAC;IAED;;;;OAIG;IACU,cAAc,CAAC,OAA8B;;YACzD,MAAM,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,aAAa,EAAE,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC,CAAC;QACvE,CAAC;KAAA;IAED;;;;OAIG;IACU,WAAW,CAAC,OAA2B;;YACnD,MAAM,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,aAAa,EAAE,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC,CAAC;QACpE,CAAC;KAAA;IAED;;;;OAIG;IACU,UAAU,CAAC,OAA0B;;YACjD,MAAM,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,aAAa,EAAE,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,CAAC;QACnE,CAAC;KAAA;IAED;;;;;;;;;;;OAWG;IACU,KAAK,CAAC,OAAqB;;YACvC,MAAM,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI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AA8B;;YACzD,MAAM,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,aAAa,EAAE,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC,CAAC;QAChE,CAAC;KAAA;IAED;;;;OAIG;IACU,WAAW,CAAC,OAA2B;;YACnD,MAAM,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,aAAa,EAAE,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC,CAAC;QAC7D,CAAC;KAAA;IAED;;;;OAIG;IACU,YAAY,CAAC,OAA4B;;YACrD,MAAM,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,aAAa,EAAE,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC,CAAC;QAC9D,CAAC;KAAA;IAED;;;;OAIG;IACU,SAAS,CAAC,OAAyB;;YAC/C,MAAM,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,aAAa,EAAE,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,CAAC;QAC3D,CAAC;KAAA;IAED;;;;OAIG;IACU,QAAQ,CAAC,OAAwB;;YAC7C,MAAM,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,aAAa,EAAE,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC;QAC1D,CAAC;KAAA;IAED;;;;OAIG;IACU,QAAQ,CAAC,OAAwB;;YAC7C,MAAM,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,aAAa,EAAE,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC;QAC1D,CAAC;KAAA;CACD;AAvJD,4DAuJC"}
package/dml/delete.d.ts CHANGED
@@ -1,8 +1,8 @@
1
+ import { Expression } from '../expression';
1
2
  import { DatabaseRecord } from '../record';
2
3
  import { Join } from './join';
3
- import { Where } from './where';
4
4
  export interface DeleteOptions<T extends DatabaseRecord = DatabaseRecord> {
5
5
  table?: string;
6
6
  join?: Join[];
7
- where: Where<T> | Where<T>[];
7
+ where: Expression<T>;
8
8
  }
@@ -0,0 +1,4 @@
1
+ import { DatabaseRecord } from '../record';
2
+ type AllowedKeys<T extends DatabaseRecord = DatabaseRecord> = keyof T & string;
3
+ export type GroupBy<T extends DatabaseRecord = DatabaseRecord> = AllowedKeys<T>[];
4
+ export {};
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=group-by.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"group-by.js","sourceRoot":"","sources":["../../../src/dml/group-by.ts"],"names":[],"mappings":""}
package/dml/index.d.ts CHANGED
@@ -1,10 +1,10 @@
1
1
  export { DatabaseQueryBuilder } from './query-builder';
2
2
  export { QueryRepository, QueryRepositoryOptions } from './query-repository';
3
- export * from './column-name';
4
3
  export * from './delete';
5
4
  export * from './insert';
6
5
  export * from './join';
6
+ export * from './group-by';
7
7
  export * from './order-by';
8
8
  export * from './select';
9
+ export * from './subquery';
9
10
  export * from './update';
10
- export * from './where';
package/dml/index.js CHANGED
@@ -19,12 +19,12 @@ var query_builder_1 = require("./query-builder");
19
19
  Object.defineProperty(exports, "DatabaseQueryBuilder", { enumerable: true, get: function () { return query_builder_1.DatabaseQueryBuilder; } });
20
20
  var query_repository_1 = require("./query-repository");
21
21
  Object.defineProperty(exports, "QueryRepository", { enumerable: true, get: function () { return query_repository_1.QueryRepository; } });
22
- __exportStar(require("./column-name"), exports);
23
22
  __exportStar(require("./delete"), exports);
24
23
  __exportStar(require("./insert"), exports);
25
24
  __exportStar(require("./join"), exports);
25
+ __exportStar(require("./group-by"), exports);
26
26
  __exportStar(require("./order-by"), exports);
27
27
  __exportStar(require("./select"), exports);
28
+ __exportStar(require("./subquery"), exports);
28
29
  __exportStar(require("./update"), exports);
29
- __exportStar(require("./where"), exports);
30
30
  //# sourceMappingURL=index.js.map
package/dml/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/dml/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,iDAAuD;AAA9C,qHAAA,oBAAoB,OAAA;AAC7B,uDAA6E;AAApE,mHAAA,eAAe,OAAA;AAExB,gDAA8B;AAC9B,2CAAyB;AACzB,2CAAyB;AACzB,yCAAuB;AACvB,6CAA2B;AAC3B,2CAAyB;AACzB,2CAAyB;AACzB,0CAAwB"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/dml/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,iDAAuD;AAA9C,qHAAA,oBAAoB,OAAA;AAC7B,uDAA6E;AAApE,mHAAA,eAAe,OAAA;AAExB,2CAAyB;AACzB,2CAAyB;AACzB,yCAAuB;AACvB,6CAA2B;AAC3B,6CAA2B;AAC3B,2CAAyB;AACzB,6CAA2B;AAC3B,2CAAyB"}
package/dml/insert.d.ts CHANGED
@@ -1,11 +1,14 @@
1
1
  import { DatabaseRecord } from '../record';
2
- export interface InsertOptions<T extends DatabaseRecord = DatabaseRecord> {
2
+ export interface BaseInsertOptions<T extends DatabaseRecord = DatabaseRecord> {
3
3
  table?: string;
4
- records: Partial<T> | Partial<T>[];
5
4
  ifNotExists?: boolean;
6
5
  onDuplicateKeyUpdate?: Partial<T>;
7
6
  primaryKey?: string;
8
7
  }
9
- export interface InsertOneOptions<T extends DatabaseRecord = DatabaseRecord> extends InsertOptions<T> {
10
- records: Partial<T>;
8
+ export interface InsertOptions<T extends DatabaseRecord = DatabaseRecord> extends BaseInsertOptions<T> {
9
+ records: Partial<T> | Partial<T>[];
10
+ }
11
+ export interface InsertOneOptions<T extends DatabaseRecord = DatabaseRecord> extends BaseInsertOptions<T> {
12
+ record: Partial<T>;
13
+ ignoreReturnId?: boolean;
11
14
  }
package/dml/join.d.ts CHANGED
@@ -1,15 +1,15 @@
1
- import { Where } from './where';
1
+ import { Expression } from '../expression';
2
2
  export interface BaseJoin {
3
3
  table: string;
4
4
  alias?: string;
5
5
  }
6
6
  export interface InnerCrossJoin extends BaseJoin {
7
7
  type?: 'INNER' | 'CROSS';
8
- on?: Where;
8
+ on?: Expression;
9
9
  }
10
10
  export interface LeftRightJoin extends BaseJoin {
11
11
  type?: 'LEFT' | 'RIGHT';
12
12
  outer?: boolean;
13
- on: Where;
13
+ on: Expression;
14
14
  }
15
15
  export type Join = InnerCrossJoin | LeftRightJoin;
@@ -1,51 +1,72 @@
1
1
  import { InsertOptions } from './insert';
2
- import { Where, WhereCondition } from './where';
3
2
  import { SelectColumn, SelectQuery } from './select';
4
3
  import { UpdateOptions } from './update';
5
4
  import { DeleteOptions } from './delete';
6
- import { Builder } from '../builder';
5
+ import { StatementBuilder } from '../builder/statement-builder';
6
+ import { GroupBy } from './group-by';
7
7
  import { OrderBy } from './order-by';
8
8
  import { Join } from './join';
9
- export declare class DatabaseQueryBuilder extends Builder {
9
+ import { ComparisonToken } from '../comparison';
10
+ import { Expression, LogicalToken } from '../expression';
11
+ import { DatabaseFunction } from '../functions/function-token';
12
+ import { Subquery } from './subquery';
13
+ import { KeyValExpression } from '../expression/key-val-expression';
14
+ export declare class DatabaseQueryBuilder extends StatementBuilder {
15
+ expression(expr: Expression | LogicalToken): void;
16
+ subquery(subquery: Subquery): void;
17
+ keyValueExpression(kv: KeyValExpression): this;
10
18
  selectColumn(column: SelectColumn): this;
11
19
  selectColumnList(columns?: SelectColumn[]): this;
12
20
  selectFrom(from: string): this;
21
+ tableAlias(alias: string): this;
13
22
  selectStatement(): this;
23
+ distinctStatement(): this;
14
24
  selectTop(limit: number): this;
15
- equals(value: any): void;
16
- like(value: any): void;
17
- lt(value: any): void;
18
- lte(value: any): void;
19
- gt(value: any): void;
20
- gte(value: any): void;
21
- notEqual(value: any): void;
25
+ equal(value: Expression): void;
26
+ like(value: Expression): void;
27
+ lt(value: Expression): void;
28
+ lte(value: Expression): void;
29
+ gt(value: Expression): void;
30
+ gte(value: Expression): void;
31
+ notEqual(value: Expression): void;
32
+ isNull(): void;
33
+ inArray(values: Expression[]): void;
34
+ between(a: Expression, b: Expression): void;
35
+ notNull(): void;
36
+ buildComparisonToken(condition: ComparisonToken): this;
22
37
  and(): void;
23
38
  or(): void;
24
- isNull(): void;
25
- in(values: any[]): void;
26
- isRiaoCondition(value: any): boolean;
27
- riaoCondition(condition: WhereCondition): this;
28
- whereClause(where: Where | Where[] | WhereCondition): this;
29
- where(where: Where | Where[]): this;
39
+ not(value: Expression): void;
40
+ logical(token: LogicalToken): void;
41
+ where(where: Expression): this;
30
42
  limit(nRecords: number): this;
43
+ groupBy(by: GroupBy): this;
31
44
  orderBy(by: OrderBy): void;
32
45
  select(query: SelectQuery): this;
33
46
  join(join: Join): void;
34
47
  insertIntoStatement(table: string): this;
35
- insertColumnNames(record: Record<string, any>): this;
36
- insertOnDuplicateKeyUpdate(assignment: Record<string, any>): this;
48
+ insertColumnNames(record: Record<string, Expression>): this;
49
+ insertOnDuplicateKeyUpdate(assignment: Record<string, Expression>): this;
37
50
  insertIfNotExists(): this;
38
51
  insertOutput(primaryKey: string): this;
39
52
  insertReturning(primaryKey: string): this;
40
53
  insert(options: InsertOptions): this;
41
54
  updateStatement(table: string): this;
42
55
  updateKeyValues(values: {
43
- [key: string]: any;
56
+ [key: string]: Expression;
44
57
  }): this;
45
58
  updateSetStatement(values: {
46
- [key: string]: any;
59
+ [key: string]: Expression;
47
60
  }): this;
48
61
  update(options: UpdateOptions): this;
49
62
  deleteStatement(table: string): this;
50
63
  delete(options: DeleteOptions): this;
64
+ /**
65
+ * Append a database function the query
66
+ *
67
+ * @param fn Database function token
68
+ */
69
+ databaseFunction(fn: DatabaseFunction): this;
70
+ count(fn: DatabaseFunction): this;
71
+ currentTimestamp(fn: DatabaseFunction): this;
51
72
  }