@abedmurrar/objection 4.0.0-alpha.0 → 4.0.0-beta.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 (192) hide show
  1. package/README.md +103 -67
  2. package/lib/index.mjs +6 -0
  3. package/lib/initialize.js +6 -9
  4. package/lib/model/AjvValidator.js +235 -282
  5. package/lib/model/Model.js +653 -823
  6. package/lib/model/ModifierNotFoundError.js +5 -7
  7. package/lib/model/NotFoundError.js +14 -18
  8. package/lib/model/RelationDoesNotExistError.js +6 -9
  9. package/lib/model/ValidationError.js +33 -41
  10. package/lib/model/Validator.js +15 -21
  11. package/lib/model/getModel.js +1 -3
  12. package/lib/model/graph/ModelGraph.js +44 -64
  13. package/lib/model/graph/ModelGraphBuilder.js +164 -217
  14. package/lib/model/graph/ModelGraphEdge.js +31 -43
  15. package/lib/model/graph/ModelGraphNode.js +192 -231
  16. package/lib/model/inheritModel.js +9 -18
  17. package/lib/model/modelBindKnex.js +48 -62
  18. package/lib/model/modelClone.js +79 -98
  19. package/lib/model/modelColPropMap.js +16 -26
  20. package/lib/model/modelConcurrency.js +24 -0
  21. package/lib/model/modelId.js +44 -49
  22. package/lib/model/modelJsonAttributes.js +56 -76
  23. package/lib/model/modelParseRelations.js +68 -67
  24. package/lib/model/modelQueryProps.js +76 -107
  25. package/lib/model/modelSet.js +92 -112
  26. package/lib/model/modelTableMetadata.js +60 -72
  27. package/lib/model/modelToJson.js +120 -150
  28. package/lib/model/modelUtils.js +30 -37
  29. package/lib/model/modelValidate.js +34 -42
  30. package/lib/model/modelValues.js +78 -91
  31. package/lib/model/modelVisitor.js +22 -29
  32. package/lib/objection.js +42 -67
  33. package/lib/queryBuilder/FunctionBuilder.js +231 -279
  34. package/lib/queryBuilder/InternalOptions.js +19 -24
  35. package/lib/queryBuilder/JoinBuilder.js +116 -149
  36. package/lib/queryBuilder/QueryBuilder.js +1009 -1271
  37. package/lib/queryBuilder/QueryBuilderBase.js +647 -865
  38. package/lib/queryBuilder/QueryBuilderContext.js +14 -21
  39. package/lib/queryBuilder/QueryBuilderContextBase.js +20 -29
  40. package/lib/queryBuilder/QueryBuilderOperationSupport.js +462 -536
  41. package/lib/queryBuilder/QueryBuilderUserContext.js +19 -25
  42. package/lib/queryBuilder/RawBuilder.js +58 -73
  43. package/lib/queryBuilder/ReferenceBuilder.js +232 -270
  44. package/lib/queryBuilder/RelationExpression.js +322 -380
  45. package/lib/queryBuilder/StaticHookArguments.js +94 -106
  46. package/lib/queryBuilder/ValueBuilder.js +100 -112
  47. package/lib/queryBuilder/expressions.js +86 -116
  48. package/lib/queryBuilder/functions/mysql.js +642 -697
  49. package/lib/queryBuilder/graph/GraphAction.js +44 -59
  50. package/lib/queryBuilder/graph/GraphData.js +7 -9
  51. package/lib/queryBuilder/graph/GraphFetcher.js +115 -151
  52. package/lib/queryBuilder/graph/GraphNodeDbExistence.js +114 -152
  53. package/lib/queryBuilder/graph/GraphOperation.js +16 -22
  54. package/lib/queryBuilder/graph/GraphOptions.js +143 -185
  55. package/lib/queryBuilder/graph/GraphUpsert.js +167 -241
  56. package/lib/queryBuilder/graph/delete/GraphDelete.js +8 -13
  57. package/lib/queryBuilder/graph/delete/GraphDeleteAction.js +44 -62
  58. package/lib/queryBuilder/graph/insert/GraphInsert.js +99 -128
  59. package/lib/queryBuilder/graph/insert/GraphInsertAction.js +151 -193
  60. package/lib/queryBuilder/graph/insert/JoinRowGraphInsertAction.js +57 -79
  61. package/lib/queryBuilder/graph/patch/GraphPatch.js +8 -13
  62. package/lib/queryBuilder/graph/patch/GraphPatchAction.js +181 -234
  63. package/lib/queryBuilder/graph/recursiveUpsert/GraphRecursiveUpsert.js +16 -21
  64. package/lib/queryBuilder/graph/recursiveUpsert/GraphRecursiveUpsertAction.js +80 -110
  65. package/lib/queryBuilder/join/JoinResultColumn.js +14 -18
  66. package/lib/queryBuilder/join/JoinResultParser.js +88 -101
  67. package/lib/queryBuilder/join/RelationJoiner.js +205 -288
  68. package/lib/queryBuilder/join/TableNode.js +117 -144
  69. package/lib/queryBuilder/join/TableTree.js +60 -76
  70. package/lib/queryBuilder/join/utils.js +10 -16
  71. package/lib/queryBuilder/operations/DelegateOperation.js +93 -133
  72. package/lib/queryBuilder/operations/DeleteOperation.js +33 -37
  73. package/lib/queryBuilder/operations/FindByIdOperation.js +20 -28
  74. package/lib/queryBuilder/operations/FindByIdsOperation.js +17 -23
  75. package/lib/queryBuilder/operations/FindOperation.js +114 -131
  76. package/lib/queryBuilder/operations/FirstOperation.js +14 -19
  77. package/lib/queryBuilder/operations/FromOperation.js +69 -88
  78. package/lib/queryBuilder/operations/InsertAndFetchOperation.js +28 -39
  79. package/lib/queryBuilder/operations/InsertGraphAndFetchOperation.js +25 -35
  80. package/lib/queryBuilder/operations/InsertGraphOperation.js +77 -98
  81. package/lib/queryBuilder/operations/InsertOperation.js +132 -165
  82. package/lib/queryBuilder/operations/InstanceDeleteOperation.js +27 -36
  83. package/lib/queryBuilder/operations/InstanceFindOperation.js +9 -13
  84. package/lib/queryBuilder/operations/InstanceInsertOperation.js +13 -17
  85. package/lib/queryBuilder/operations/InstanceUpdateOperation.js +32 -46
  86. package/lib/queryBuilder/operations/JoinRelatedOperation.js +66 -86
  87. package/lib/queryBuilder/operations/KnexOperation.js +4 -7
  88. package/lib/queryBuilder/operations/MergeOperation.js +32 -45
  89. package/lib/queryBuilder/operations/ObjectionToKnexConvertingOperation.js +131 -150
  90. package/lib/queryBuilder/operations/OnBuildKnexOperation.js +17 -23
  91. package/lib/queryBuilder/operations/OnBuildOperation.js +17 -23
  92. package/lib/queryBuilder/operations/OnErrorOperation.js +17 -23
  93. package/lib/queryBuilder/operations/QueryBuilderOperation.js +231 -270
  94. package/lib/queryBuilder/operations/RangeOperation.js +30 -40
  95. package/lib/queryBuilder/operations/RelateOperation.js +14 -21
  96. package/lib/queryBuilder/operations/ReturningOperation.js +12 -18
  97. package/lib/queryBuilder/operations/RunAfterOperation.js +17 -23
  98. package/lib/queryBuilder/operations/RunBeforeOperation.js +17 -23
  99. package/lib/queryBuilder/operations/UnrelateOperation.js +12 -17
  100. package/lib/queryBuilder/operations/UpdateAndFetchOperation.js +48 -65
  101. package/lib/queryBuilder/operations/UpdateOperation.js +104 -129
  102. package/lib/queryBuilder/operations/UpsertGraphAndFetchOperation.js +25 -35
  103. package/lib/queryBuilder/operations/UpsertGraphOperation.js +36 -55
  104. package/lib/queryBuilder/operations/WhereCompositeOperation.js +30 -39
  105. package/lib/queryBuilder/operations/WhereInOperation.js +34 -36
  106. package/lib/queryBuilder/operations/eager/EagerOperation.js +37 -52
  107. package/lib/queryBuilder/operations/eager/JoinEagerOperation.js +34 -44
  108. package/lib/queryBuilder/operations/eager/NaiveEagerOperation.js +4 -7
  109. package/lib/queryBuilder/operations/eager/WhereInEagerOperation.js +193 -251
  110. package/lib/queryBuilder/operations/jsonApi/WhereJsonHasOperation.js +18 -25
  111. package/lib/queryBuilder/operations/jsonApi/WhereJsonNotObjectOperation.js +25 -41
  112. package/lib/queryBuilder/operations/jsonApi/WhereJsonOperation.js +19 -20
  113. package/lib/queryBuilder/operations/jsonApi/WhereJsonOverlapsOperation.js +23 -21
  114. package/lib/queryBuilder/operations/jsonApi/mysqlJsonApi.js +106 -118
  115. package/lib/queryBuilder/operations/jsonApi/postgresJsonApi.js +79 -108
  116. package/lib/queryBuilder/operations/select/SelectOperation.js +37 -53
  117. package/lib/queryBuilder/operations/select/Selection.js +94 -105
  118. package/lib/queryBuilder/operations/whereInComposite/WhereInCompositeMsSqlOperation.js +68 -101
  119. package/lib/queryBuilder/operations/whereInComposite/WhereInCompositeOperation.js +65 -75
  120. package/lib/queryBuilder/operations/whereInComposite/WhereInCompositeSqliteOperation.js +75 -84
  121. package/lib/queryBuilder/parsers/jsonFieldExpressionParser.js +760 -859
  122. package/lib/queryBuilder/parsers/relationExpressionParser.js +840 -952
  123. package/lib/queryBuilder/transformations/CompositeQueryTransformation.js +10 -15
  124. package/lib/queryBuilder/transformations/QueryTransformation.js +4 -6
  125. package/lib/queryBuilder/transformations/WrapMysqlModifySubqueryTransformation.js +35 -49
  126. package/lib/queryBuilder/transformations/index.js +3 -9
  127. package/lib/queryBuilder/whereScopes.js +158 -186
  128. package/lib/relations/Relation.js +279 -363
  129. package/lib/relations/RelationDeleteOperation.js +16 -22
  130. package/lib/relations/RelationFindOperation.js +100 -133
  131. package/lib/relations/RelationInsertOperation.js +19 -27
  132. package/lib/relations/RelationOwner.js +167 -204
  133. package/lib/relations/RelationProperty.js +177 -217
  134. package/lib/relations/RelationUpdateOperation.js +16 -23
  135. package/lib/relations/belongsToOne/BelongsToOneDeleteOperation.js +11 -16
  136. package/lib/relations/belongsToOne/BelongsToOneInsertOperation.js +24 -35
  137. package/lib/relations/belongsToOne/BelongsToOneRelateOperation.js +30 -41
  138. package/lib/relations/belongsToOne/BelongsToOneRelation.js +33 -41
  139. package/lib/relations/belongsToOne/BelongsToOneUnrelateOperation.js +38 -53
  140. package/lib/relations/hasMany/HasManyInsertOperation.js +35 -51
  141. package/lib/relations/hasMany/HasManyRelateOperation.js +38 -54
  142. package/lib/relations/hasMany/HasManyRelation.js +30 -38
  143. package/lib/relations/hasMany/HasManyUnrelateOperation.js +19 -26
  144. package/lib/relations/hasOne/HasOneRelation.js +4 -7
  145. package/lib/relations/hasOneThrough/HasOneThroughRelation.js +4 -7
  146. package/lib/relations/manyToMany/ManyToManyModifyMixin.js +67 -90
  147. package/lib/relations/manyToMany/ManyToManyRelation.js +349 -451
  148. package/lib/relations/manyToMany/ManyToManySqliteModifyMixin.js +19 -26
  149. package/lib/relations/manyToMany/delete/ManyToManyDeleteOperation.js +3 -5
  150. package/lib/relations/manyToMany/delete/ManyToManyDeleteOperationBase.js +14 -20
  151. package/lib/relations/manyToMany/delete/ManyToManyDeleteSqliteOperation.js +3 -7
  152. package/lib/relations/manyToMany/find/ManyToManyFindOperation.js +71 -94
  153. package/lib/relations/manyToMany/insert/ManyToManyInsertOperation.js +31 -43
  154. package/lib/relations/manyToMany/relate/ManyToManyRelateOperation.js +50 -67
  155. package/lib/relations/manyToMany/unrelate/ManyToManyUnrelateOperation.js +4 -7
  156. package/lib/relations/manyToMany/unrelate/ManyToManyUnrelateOperationBase.js +20 -27
  157. package/lib/relations/manyToMany/unrelate/ManyToManyUnrelateSqliteOperation.js +5 -10
  158. package/lib/relations/manyToMany/update/ManyToManyUpdateOperation.js +3 -5
  159. package/lib/relations/manyToMany/update/ManyToManyUpdateOperationBase.js +55 -72
  160. package/lib/relations/manyToMany/update/ManyToManyUpdateSqliteOperation.js +3 -7
  161. package/lib/transaction.js +53 -83
  162. package/lib/utils/assert.js +15 -21
  163. package/lib/utils/buildUtils.js +17 -19
  164. package/lib/utils/classUtils.js +7 -11
  165. package/lib/utils/cloneDeep.js +365 -0
  166. package/lib/utils/createModifier.js +36 -41
  167. package/lib/utils/deprecate.js +8 -12
  168. package/lib/utils/identifierMapping.js +153 -192
  169. package/lib/utils/internalPropUtils.js +4 -8
  170. package/lib/utils/knexUtils.js +61 -56
  171. package/lib/utils/mixin.js +16 -23
  172. package/lib/utils/mysqlJsonPath.js +55 -40
  173. package/lib/utils/normalizeIds.js +110 -127
  174. package/lib/utils/objectUtils.js +236 -338
  175. package/lib/utils/parseFieldExpression.js +66 -44
  176. package/lib/utils/postgresJsonPath.js +48 -62
  177. package/lib/utils/promiseUtils/after.js +10 -13
  178. package/lib/utils/promiseUtils/afterReturn.js +10 -13
  179. package/lib/utils/promiseUtils/index.js +15 -17
  180. package/lib/utils/promiseUtils/isPromise.js +6 -9
  181. package/lib/utils/promiseUtils/map.js +75 -89
  182. package/lib/utils/promiseUtils/mapAfterAllReturn.js +17 -23
  183. package/lib/utils/promiseUtils/try.js +15 -18
  184. package/lib/utils/resolveModel.js +91 -94
  185. package/lib/utils/tmpColumnUtils.js +4 -13
  186. package/package.json +50 -23
  187. package/typings/objection/index.d.mts +362 -0
  188. package/typings/objection/index.d.ts +36 -9
  189. package/lib/.eslintrc.json +0 -8
  190. package/lib/queryBuilder/parsers/jsonFieldExpressionParser.pegjs +0 -97
  191. package/lib/queryBuilder/parsers/relationExpressionParser.pegjs +0 -141
  192. package/lib/utils/clone.js +0 -2329
@@ -1,884 +1,666 @@
1
1
  'use strict';
2
-
3
2
  const { QueryBuilderOperationSupport } = require('./QueryBuilderOperationSupport');
4
3
  const { isSqlite, isMsSql } = require('../utils/knexUtils');
5
-
6
4
  const { KnexOperation } = require('./operations/KnexOperation');
5
+ const HavingSelector = /^(having|orHaving|andHaving)/;
6
+ const GroupBySelector = /^groupBy/;
7
7
  const { expression } = require('./expressions');
8
- const { WhereInOperation } = require('./operations/WhereInOperation');
9
8
  const { MergeOperation } = require('./operations/MergeOperation');
10
9
  const { SelectOperation } = require('./operations/select/SelectOperation');
11
10
  const { ReturningOperation } = require('./operations/ReturningOperation');
12
11
  const { WhereCompositeOperation } = require('./operations/WhereCompositeOperation');
13
12
  const { WhereJsonOperation } = require('./operations/jsonApi/WhereJsonOperation');
14
13
  const { WhereJsonOverlapsOperation } = require('./operations/jsonApi/WhereJsonOverlapsOperation');
15
-
16
- const {
17
- WhereInCompositeOperation,
18
- } = require('./operations/whereInComposite/WhereInCompositeOperation');
19
- const {
20
- WhereInCompositeSqliteOperation,
21
- } = require('./operations/whereInComposite/WhereInCompositeSqliteOperation');
22
- const {
23
- WhereInCompositeMsSqlOperation,
24
- } = require('./operations/whereInComposite/WhereInCompositeMsSqlOperation');
14
+ const { WhereInCompositeOperation, } = require('./operations/whereInComposite/WhereInCompositeOperation');
15
+ const { WhereInCompositeSqliteOperation, } = require('./operations/whereInComposite/WhereInCompositeSqliteOperation');
16
+ const { WhereInCompositeMsSqlOperation, } = require('./operations/whereInComposite/WhereInCompositeMsSqlOperation');
25
17
  const { WhereJsonHasOperation } = require('./operations/jsonApi/WhereJsonHasOperation');
26
18
  const { WhereJsonNotObjectOperation } = require('./operations/jsonApi/WhereJsonNotObjectOperation');
27
-
28
19
  class QueryBuilderBase extends QueryBuilderOperationSupport {
29
- modify(...args) {
30
- const func = args[0];
31
-
32
- if (!func) {
33
- return this;
34
- }
35
-
36
- if (args.length === 1) {
37
- func.call(this, this);
38
- } else {
39
- args[0] = this;
40
- func(...args);
41
- }
42
-
43
- return this;
44
- }
45
-
46
- transacting(trx) {
47
- this._context.knex = trx || null;
48
- return this;
49
- }
50
-
51
- select(...args) {
52
- return this.addOperation(new SelectOperation('select'), args);
53
- }
54
-
55
- insert(...args) {
56
- return this.addOperation(new KnexOperation('insert'), args);
57
- }
58
-
59
- update(...args) {
60
- return this.addOperation(new KnexOperation('update'), args);
61
- }
62
-
63
- delete(...args) {
64
- return this.addOperation(new KnexOperation('delete'), args);
65
- }
66
-
67
- del(...args) {
68
- return this.delete(...args);
69
- }
70
-
71
- forUpdate(...args) {
72
- return this.addOperation(new KnexOperation('forUpdate'), args);
73
- }
74
-
75
- forShare(...args) {
76
- return this.addOperation(new KnexOperation('forShare'), args);
77
- }
78
-
79
- forNoKeyUpdate(...args) {
80
- return this.addOperation(new KnexOperation('forNoKeyUpdate'), args);
81
- }
82
-
83
- forKeyShare(...args) {
84
- return this.addOperation(new KnexOperation('forKeyShare'), args);
85
- }
86
-
87
- skipLocked(...args) {
88
- return this.addOperation(new KnexOperation('skipLocked'), args);
89
- }
90
-
91
- noWait(...args) {
92
- return this.addOperation(new KnexOperation('noWait'), args);
93
- }
94
-
95
- as(...args) {
96
- return this.addOperation(new KnexOperation('as'), args);
97
- }
98
-
99
- columns(...args) {
100
- return this.addOperation(new SelectOperation('columns'), args);
101
- }
102
-
103
- column(...args) {
104
- return this.addOperation(new SelectOperation('column'), args);
105
- }
106
-
107
- from(...args) {
108
- return this.addOperation(new KnexOperation('from'), args);
109
- }
110
-
111
- fromJS(...args) {
112
- return this.addOperation(new KnexOperation('fromJS'), args);
113
- }
114
-
115
- fromRaw(...args) {
116
- return this.addOperation(new KnexOperation('fromRaw'), args);
117
- }
118
-
119
- into(...args) {
120
- return this.addOperation(new KnexOperation('into'), args);
121
- }
122
-
123
- withSchema(...args) {
124
- return this.addOperation(new KnexOperation('withSchema'), args);
125
- }
126
-
127
- table(...args) {
128
- return this.addOperation(new KnexOperation('table'), args);
129
- }
130
-
131
- distinct(...args) {
132
- return this.addOperation(new SelectOperation('distinct'), args);
133
- }
134
-
135
- distinctOn(...args) {
136
- return this.addOperation(new SelectOperation('distinctOn'), args);
137
- }
138
-
139
- join(...args) {
140
- return this.addOperation(new KnexOperation('join'), args);
141
- }
142
-
143
- joinRaw(...args) {
144
- return this.addOperation(new KnexOperation('joinRaw'), args);
145
- }
146
-
147
- innerJoin(...args) {
148
- return this.addOperation(new KnexOperation('innerJoin'), args);
149
- }
150
-
151
- leftJoin(...args) {
152
- return this.addOperation(new KnexOperation('leftJoin'), args);
153
- }
154
-
155
- leftOuterJoin(...args) {
156
- return this.addOperation(new KnexOperation('leftOuterJoin'), args);
157
- }
158
-
159
- rightJoin(...args) {
160
- return this.addOperation(new KnexOperation('rightJoin'), args);
161
- }
162
-
163
- rightOuterJoin(...args) {
164
- return this.addOperation(new KnexOperation('rightOuterJoin'), args);
165
- }
166
-
167
- outerJoin(...args) {
168
- return this.addOperation(new KnexOperation('outerJoin'), args);
169
- }
170
-
171
- fullOuterJoin(...args) {
172
- return this.addOperation(new KnexOperation('fullOuterJoin'), args);
173
- }
174
-
175
- crossJoin(...args) {
176
- return this.addOperation(new KnexOperation('crossJoin'), args);
177
- }
178
-
179
- where(...args) {
180
- return this.addOperation(new KnexOperation('where'), args);
181
- }
182
-
183
- andWhere(...args) {
184
- return this.addOperation(new KnexOperation('andWhere'), args);
185
- }
186
-
187
- orWhere(...args) {
188
- return this.addOperation(new KnexOperation('orWhere'), args);
189
- }
190
-
191
- whereNot(...args) {
192
- return this.addOperation(new KnexOperation('whereNot'), args);
193
- }
194
-
195
- andWhereNot(...args) {
196
- return this.addOperation(new KnexOperation('andWhereNot'), args);
197
- }
198
-
199
- orWhereNot(...args) {
200
- return this.addOperation(new KnexOperation('orWhereNot'), args);
201
- }
202
-
203
- // Makes the query match no rows.
204
- none() {
205
- return this.where(expression('(1 = 0)', []));
206
- }
207
-
208
- whereRaw(...args) {
209
- return this.addOperation(new KnexOperation('whereRaw'), args);
210
- }
211
-
212
- andWhereRaw(...args) {
213
- return this.addOperation(new KnexOperation('andWhereRaw'), args);
214
- }
215
-
216
- orWhereRaw(...args) {
217
- return this.addOperation(new KnexOperation('orWhereRaw'), args);
218
- }
219
-
220
- whereWrapped(...args) {
221
- return this.addOperation(new KnexOperation('whereWrapped'), args);
222
- }
223
-
224
- havingWrapped(...args) {
225
- return this.addOperation(new KnexOperation('havingWrapped'), args);
226
- }
227
-
228
- whereExists(...args) {
229
- return this.addOperation(new KnexOperation('whereExists'), args);
230
- }
231
-
232
- orWhereExists(...args) {
233
- return this.addOperation(new KnexOperation('orWhereExists'), args);
234
- }
235
-
236
- whereNotExists(...args) {
237
- return this.addOperation(new KnexOperation('whereNotExists'), args);
238
- }
239
-
240
- orWhereNotExists(...args) {
241
- return this.addOperation(new KnexOperation('orWhereNotExists'), args);
242
- }
243
-
244
- whereIn(...args) {
245
- return this.addOperation(new WhereInOperation('whereIn', { rawMethod: 'where' }), args);
246
- }
247
-
248
- orWhereIn(...args) {
249
- return this.addOperation(new WhereInOperation('orWhereIn', { rawMethod: 'orWhere' }), args);
250
- }
251
-
252
- whereNotIn(...args) {
253
- return this.addOperation(
254
- new WhereInOperation('whereNotIn', { rawMethod: 'where', not: true }),
255
- args,
256
- );
257
- }
258
-
259
- orWhereNotIn(...args) {
260
- return this.addOperation(
261
- new WhereInOperation('orWhereNotIn', { rawMethod: 'orWhere', not: true }),
262
- args,
263
- );
264
- }
265
-
266
- whereNull(...args) {
267
- return this.addOperation(new KnexOperation('whereNull'), args);
268
- }
269
-
270
- orWhereNull(...args) {
271
- return this.addOperation(new KnexOperation('orWhereNull'), args);
272
- }
273
-
274
- whereNotNull(...args) {
275
- return this.addOperation(new KnexOperation('whereNotNull'), args);
276
- }
277
-
278
- orWhereNotNull(...args) {
279
- return this.addOperation(new KnexOperation('orWhereNotNull'), args);
280
- }
281
-
282
- whereBetween(...args) {
283
- return this.addOperation(new KnexOperation('whereBetween'), args);
284
- }
285
-
286
- andWhereBetween(...args) {
287
- return this.addOperation(new KnexOperation('andWhereBetween'), args);
288
- }
289
-
290
- whereNotBetween(...args) {
291
- return this.addOperation(new KnexOperation('whereNotBetween'), args);
292
- }
293
-
294
- andWhereNotBetween(...args) {
295
- return this.addOperation(new KnexOperation('andWhereNotBetween'), args);
296
- }
297
-
298
- orWhereBetween(...args) {
299
- return this.addOperation(new KnexOperation('orWhereBetween'), args);
300
- }
301
-
302
- orWhereNotBetween(...args) {
303
- return this.addOperation(new KnexOperation('orWhereNotBetween'), args);
304
- }
305
-
306
- whereLike(...args) {
307
- return this.addOperation(new KnexOperation('whereLike'), args);
308
- }
309
-
310
- andWhereLike(...args) {
311
- return this.addOperation(new KnexOperation('andWhereLike'), args);
312
- }
313
-
314
- orWhereLike(...args) {
315
- return this.addOperation(new KnexOperation('orWhereLike'), args);
316
- }
317
-
318
- whereILike(...args) {
319
- return this.addOperation(new KnexOperation('whereILike'), args);
320
- }
321
-
322
- andWhereILike(...args) {
323
- return this.addOperation(new KnexOperation('andWhereILike'), args);
324
- }
325
-
326
- orWhereILike(...args) {
327
- return this.addOperation(new KnexOperation('orWhereILike'), args);
328
- }
329
-
330
- groupBy(...args) {
331
- return this.addOperation(new KnexOperation('groupBy'), args);
332
- }
333
-
334
- groupByRaw(...args) {
335
- return this.addOperation(new KnexOperation('groupByRaw'), args);
336
- }
337
-
338
- orderBy(...args) {
339
- return this.addOperation(new KnexOperation('orderBy'), args);
340
- }
341
-
342
- orderByRaw(...args) {
343
- return this.addOperation(new KnexOperation('orderByRaw'), args);
344
- }
345
-
346
- union(...args) {
347
- return this.addOperation(new KnexOperation('union'), args);
348
- }
349
-
350
- unionAll(...args) {
351
- return this.addOperation(new KnexOperation('unionAll'), args);
352
- }
353
-
354
- intersect(...args) {
355
- return this.addOperation(new KnexOperation('intersect'), args);
356
- }
357
-
358
- except(...args) {
359
- return this.addOperation(new KnexOperation('except'), args);
360
- }
361
-
362
- having(...args) {
363
- return this.addOperation(new KnexOperation('having'), args);
364
- }
365
-
366
- clearHaving(...args) {
367
- return this.addOperation(new KnexOperation('clearHaving'), args);
368
- }
369
-
370
- clearGroup(...args) {
371
- return this.addOperation(new KnexOperation('clearGroup'), args);
372
- }
373
-
374
- orHaving(...args) {
375
- return this.addOperation(new KnexOperation('orHaving'), args);
376
- }
377
-
378
- havingIn(...args) {
379
- return this.addOperation(new KnexOperation('havingIn'), args);
380
- }
381
-
382
- orHavingIn(...args) {
383
- return this.addOperation(new KnexOperation('havingIn'), args);
384
- }
385
-
386
- havingNotIn(...args) {
387
- return this.addOperation(new KnexOperation('havingNotIn'), args);
388
- }
389
-
390
- orHavingNotIn(...args) {
391
- return this.addOperation(new KnexOperation('orHavingNotIn'), args);
392
- }
393
-
394
- havingNull(...args) {
395
- return this.addOperation(new KnexOperation('havingNull'), args);
396
- }
397
-
398
- orHavingNull(...args) {
399
- return this.addOperation(new KnexOperation('orHavingNull'), args);
400
- }
401
-
402
- havingNotNull(...args) {
403
- return this.addOperation(new KnexOperation('havingNotNull'), args);
404
- }
405
-
406
- orHavingNotNull(...args) {
407
- return this.addOperation(new KnexOperation('orHavingNotNull'), args);
408
- }
409
-
410
- havingExists(...args) {
411
- return this.addOperation(new KnexOperation('havingExists'), args);
412
- }
413
-
414
- orHavingExists(...args) {
415
- return this.addOperation(new KnexOperation('orHavingExists'), args);
416
- }
417
-
418
- havingNotExists(...args) {
419
- return this.addOperation(new KnexOperation('havingNotExists'), args);
420
- }
421
-
422
- orHavingNotExists(...args) {
423
- return this.addOperation(new KnexOperation('orHavingNotExists'), args);
424
- }
425
-
426
- havingBetween(...args) {
427
- return this.addOperation(new KnexOperation('havingBetween'), args);
428
- }
429
-
430
- orHavingBetween(...args) {
431
- return this.addOperation(new KnexOperation('havingBetween'), args);
432
- }
433
-
434
- havingNotBetween(...args) {
435
- return this.addOperation(new KnexOperation('havingNotBetween'), args);
436
- }
437
-
438
- orHavingNotBetween(...args) {
439
- return this.addOperation(new KnexOperation('havingNotBetween'), args);
440
- }
441
-
442
- havingRaw(...args) {
443
- return this.addOperation(new KnexOperation('havingRaw'), args);
444
- }
445
-
446
- orHavingRaw(...args) {
447
- return this.addOperation(new KnexOperation('orHavingRaw'), args);
448
- }
449
-
450
- offset(...args) {
451
- return this.addOperation(new KnexOperation('offset'), args);
452
- }
453
-
454
- limit(...args) {
455
- return this.addOperation(new KnexOperation('limit'), args);
456
- }
457
-
458
- count(...args) {
459
- return this.addOperation(new SelectOperation('count'), args);
460
- }
461
-
462
- countDistinct(...args) {
463
- return this.addOperation(new SelectOperation('countDistinct'), args);
464
- }
465
-
466
- min(...args) {
467
- return this.addOperation(new SelectOperation('min'), args);
468
- }
469
-
470
- max(...args) {
471
- return this.addOperation(new SelectOperation('max'), args);
472
- }
473
-
474
- sum(...args) {
475
- return this.addOperation(new SelectOperation('sum'), args);
476
- }
477
-
478
- sumDistinct(...args) {
479
- return this.addOperation(new SelectOperation('sumDistinct'), args);
480
- }
481
-
482
- avg(...args) {
483
- return this.addOperation(new SelectOperation('avg'), args);
484
- }
485
-
486
- avgDistinct(...args) {
487
- return this.addOperation(new SelectOperation('avgDistinct'), args);
488
- }
489
-
490
- debug(...args) {
491
- return this.addOperation(new KnexOperation('debug'), args);
492
- }
493
-
494
- returning(...args) {
495
- return this.addOperation(new ReturningOperation('returning'), args);
496
- }
497
-
498
- truncate(...args) {
499
- return this.addOperation(new KnexOperation('truncate'), args);
500
- }
501
-
502
- connection(...args) {
503
- return this.addOperation(new KnexOperation('connection'), args);
504
- }
505
-
506
- options(...args) {
507
- return this.addOperation(new KnexOperation('options'), args);
508
- }
509
-
510
- columnInfo(...args) {
511
- return this.addOperation(new KnexOperation('columnInfo'), args);
512
- }
513
-
514
- off(...args) {
515
- return this.addOperation(new KnexOperation('off'), args);
516
- }
517
-
518
- timeout(...args) {
519
- return this.addOperation(new KnexOperation('timeout'), args);
520
- }
521
-
522
- with(...args) {
523
- return this.addOperation(new KnexOperation('with'), args);
524
- }
525
-
526
- withWrapped(...args) {
527
- return this.addOperation(new KnexOperation('withWrapped'), args);
528
- }
529
-
530
- withRecursive(...args) {
531
- return this.addOperation(new KnexOperation('withRecursive'), args);
532
- }
533
-
534
- withMaterialized(...args) {
535
- return this.addOperation(new KnexOperation('withMaterialized'), args);
536
- }
537
-
538
- withNotMaterialized(...args) {
539
- return this.addOperation(new KnexOperation('withNotMaterialized'), args);
540
- }
541
-
542
- whereComposite(...args) {
543
- return this.addOperation(new WhereCompositeOperation('whereComposite'), args);
544
- }
545
-
546
- whereInComposite(...args) {
547
- let operation = null;
548
-
549
- if (isSqlite(this.knex())) {
550
- operation = new WhereInCompositeSqliteOperation('whereInComposite');
551
- } else if (isMsSql(this.knex())) {
552
- operation = new WhereInCompositeMsSqlOperation('whereInComposite');
553
- } else {
554
- operation = new WhereInCompositeOperation('whereInComposite');
555
- }
556
-
557
- return this.addOperation(operation, args);
558
- }
559
-
560
- whereNotInComposite(...args) {
561
- let operation = null;
562
-
563
- if (isSqlite(this.knex())) {
564
- operation = new WhereInCompositeSqliteOperation('whereNotInComposite', { prefix: 'not' });
565
- } else if (isMsSql(this.knex())) {
566
- operation = new WhereInCompositeMsSqlOperation('whereNotInComposite', { prefix: 'not' });
567
- } else {
568
- operation = new WhereInCompositeOperation('whereNotInComposite', { prefix: 'not' });
569
- }
570
-
571
- return this.addOperation(operation, args);
572
- }
573
-
574
- jsonExtract(...args) {
575
- return this.addOperation(new KnexOperation('jsonExtract'), args);
576
- }
577
-
578
- jsonSet(...args) {
579
- return this.addOperation(new KnexOperation('jsonSet'), args);
580
- }
581
-
582
- jsonInsert(...args) {
583
- return this.addOperation(new KnexOperation('jsonInsert'), args);
584
- }
585
-
586
- jsonRemove(...args) {
587
- return this.addOperation(new KnexOperation('jsonRemove'), args);
588
- }
589
-
590
- whereJsonObject(...args) {
591
- return this.addOperation(new KnexOperation('whereJsonObject'), args);
592
- }
593
-
594
- orWhereJsonObject(...args) {
595
- return this.addOperation(new KnexOperation('orWhereJsonObject'), args);
596
- }
597
-
598
- andWhereJsonObject(...args) {
599
- return this.addOperation(new KnexOperation('andWhereJsonObject'), args);
600
- }
601
-
602
- whereNotJsonObject(...args) {
603
- return this.addOperation(new KnexOperation('whereNotJsonObject'), args);
604
- }
605
-
606
- orWhereNotJsonObject(...args) {
607
- return this.addOperation(new KnexOperation('orWhereNotJsonObject'), args);
608
- }
609
-
610
- andWhereNotJsonObject(...args) {
611
- return this.addOperation(new KnexOperation('andWhereNotJsonObject'), args);
612
- }
613
-
614
- whereJsonPath(...args) {
615
- return this.addOperation(new KnexOperation('whereJsonPath'), args);
616
- }
617
-
618
- orWhereJsonPath(...args) {
619
- return this.addOperation(new KnexOperation('orWhereJsonPath'), args);
620
- }
621
-
622
- andWhereJsonPath(...args) {
623
- return this.addOperation(new KnexOperation('andWhereJsonPath'), args);
624
- }
625
-
626
- // whereJson(Not)SupersetOf / whereJson(Not)SubsetOf are now supported by knex >= 1.0, but for now
627
- // objection handles them differently and only for postgres.
628
- // Changing them to utilize knex methods directly may require a major version bump and upgrade guide.
629
- whereJsonSupersetOf(...args) {
630
- return this.addOperation(
631
- new WhereJsonOperation('whereJsonSupersetOf', { operator: '@>', bool: 'and' }),
632
- args,
633
- );
634
- }
635
-
636
- andWhereJsonSupersetOf(...args) {
637
- return this.whereJsonSupersetOf(...args);
638
- }
639
-
640
- orWhereJsonSupersetOf(...args) {
641
- return this.addOperation(
642
- new WhereJsonOperation('orWhereJsonSupersetOf', { operator: '@>', bool: 'or' }),
643
- args,
644
- );
645
- }
646
-
647
- whereJsonNotSupersetOf(...args) {
648
- return this.addOperation(
649
- new WhereJsonOperation('whereJsonNotSupersetOf', {
650
- operator: '@>',
651
- bool: 'and',
652
- prefix: 'not',
653
- }),
654
- args,
655
- );
656
- }
657
-
658
- andWhereJsonNotSupersetOf(...args) {
659
- return this.whereJsonNotSupersetOf(...args);
660
- }
661
-
662
- orWhereJsonNotSupersetOf(...args) {
663
- return this.addOperation(
664
- new WhereJsonOperation('orWhereJsonNotSupersetOf', {
665
- operator: '@>',
666
- bool: 'or',
667
- prefix: 'not',
668
- }),
669
- args,
670
- );
671
- }
672
-
673
- whereJsonSubsetOf(...args) {
674
- return this.addOperation(
675
- new WhereJsonOperation('whereJsonSubsetOf', { operator: '<@', bool: 'and' }),
676
- args,
677
- );
678
- }
679
-
680
- andWhereJsonSubsetOf(...args) {
681
- return this.whereJsonSubsetOf(...args);
682
- }
683
-
684
- orWhereJsonSubsetOf(...args) {
685
- return this.addOperation(
686
- new WhereJsonOperation('orWhereJsonSubsetOf', { operator: '<@', bool: 'or' }),
687
- args,
688
- );
689
- }
690
-
691
- whereJsonNotSubsetOf(...args) {
692
- return this.addOperation(
693
- new WhereJsonOperation('whereJsonNotSubsetOf', {
694
- operator: '<@',
695
- bool: 'and',
696
- prefix: 'not',
697
- }),
698
- args,
699
- );
700
- }
701
-
702
- andWhereJsonNotSubsetOf(...args) {
703
- return this.whereJsonNotSubsetOf(...args);
704
- }
705
-
706
- orWhereJsonNotSubsetOf(...args) {
707
- return this.addOperation(
708
- new WhereJsonOperation('orWhereJsonNotSubsetOf', {
709
- operator: '<@',
710
- bool: 'or',
711
- prefix: 'not',
712
- }),
713
- args,
714
- );
715
- }
716
-
717
- whereJsonNotArray(...args) {
718
- return this.addOperation(
719
- new WhereJsonNotObjectOperation('whereJsonNotArray', {
720
- bool: 'and',
721
- compareValue: [],
722
- }),
723
- args,
724
- );
725
- }
726
-
727
- orWhereJsonNotArray(...args) {
728
- return this.addOperation(
729
- new WhereJsonNotObjectOperation('orWhereJsonNotArray', {
730
- bool: 'or',
731
- compareValue: [],
732
- }),
733
- args,
734
- );
735
- }
736
-
737
- whereJsonNotObject(...args) {
738
- return this.addOperation(
739
- new WhereJsonNotObjectOperation('whereJsonNotObject', {
740
- bool: 'and',
741
- compareValue: {},
742
- }),
743
- args,
744
- );
745
- }
746
-
747
- orWhereJsonNotObject(...args) {
748
- return this.addOperation(
749
- new WhereJsonNotObjectOperation('orWhereJsonNotObject', {
750
- bool: 'or',
751
- compareValue: {},
752
- }),
753
- args,
754
- );
755
- }
756
-
757
- whereJsonHasAny(...args) {
758
- return this.addOperation(
759
- new WhereJsonHasOperation('whereJsonHasAny', { bool: 'and', operator: '?|' }),
760
- args,
761
- );
762
- }
763
-
764
- orWhereJsonHasAny(...args) {
765
- return this.addOperation(
766
- new WhereJsonHasOperation('orWhereJsonHasAny', { bool: 'or', operator: '?|' }),
767
- args,
768
- );
769
- }
770
-
771
- whereJsonHasAll(...args) {
772
- return this.addOperation(
773
- new WhereJsonHasOperation('whereJsonHasAll', { bool: 'and', operator: '?&' }),
774
- args,
775
- );
776
- }
777
-
778
- orWhereJsonHasAll(...args) {
779
- return this.addOperation(
780
- new WhereJsonHasOperation('orWhereJsonHasAll', { bool: 'or', operator: '?&' }),
781
- args,
782
- );
783
- }
784
-
785
- whereJsonOverlaps(...args) {
786
- return this.addOperation(
787
- new WhereJsonOverlapsOperation('whereJsonOverlaps', { bool: 'and' }),
788
- args,
789
- );
790
- }
791
-
792
- andWhereJsonOverlaps(...args) {
793
- return this.whereJsonOverlaps(...args);
794
- }
795
-
796
- orWhereJsonOverlaps(...args) {
797
- return this.addOperation(
798
- new WhereJsonOverlapsOperation('orWhereJsonOverlaps', { bool: 'or' }),
799
- args,
800
- );
801
- }
802
-
803
- whereJsonNotOverlaps(...args) {
804
- return this.addOperation(
805
- new WhereJsonOverlapsOperation('whereJsonNotOverlaps', { bool: 'and', prefix: 'not' }),
806
- args,
807
- );
808
- }
809
-
810
- andWhereJsonNotOverlaps(...args) {
811
- return this.whereJsonNotOverlaps(...args);
812
- }
813
-
814
- orWhereJsonNotOverlaps(...args) {
815
- return this.addOperation(
816
- new WhereJsonOverlapsOperation('orWhereJsonNotOverlaps', { bool: 'or', prefix: 'not' }),
817
- args,
818
- );
819
- }
820
-
821
- whereJsonIsArray(fieldExpression) {
822
- return this.whereJsonSupersetOf(fieldExpression, []);
823
- }
824
-
825
- orWhereJsonIsArray(fieldExpression) {
826
- return this.orWhereJsonSupersetOf(fieldExpression, []);
827
- }
828
-
829
- whereJsonIsObject(fieldExpression) {
830
- return this.whereJsonSupersetOf(fieldExpression, {});
831
- }
832
-
833
- orWhereJsonIsObject(fieldExpression) {
834
- return this.orWhereJsonSupersetOf(fieldExpression, {});
835
- }
836
-
837
- whereColumn(...args) {
838
- return this.addOperation(new KnexOperation('whereColumn'), args);
839
- }
840
-
841
- andWhereColumn(...args) {
842
- return this.addOperation(new KnexOperation('andWhereColumn'), args);
843
- }
844
-
845
- orWhereColumn(...args) {
846
- return this.addOperation(new KnexOperation('orWhereColumn'), args);
847
- }
848
-
849
- whereNotColumn(...args) {
850
- return this.addOperation(new KnexOperation('whereNotColumn'), args);
851
- }
852
-
853
- andWhereNotColumn(...args) {
854
- return this.addOperation(new KnexOperation('andWhereNotColumn'), args);
855
- }
856
-
857
- orWhereNotColumn(...args) {
858
- return this.addOperation(new KnexOperation('orWhereNotColumn'), args);
859
- }
860
-
861
- onConflict(...args) {
862
- return this.addOperation(new KnexOperation('onConflict'), args);
863
- }
864
-
865
- ignore(...args) {
866
- return this.addOperation(new KnexOperation('ignore'), args);
867
- }
868
-
869
- merge(...args) {
870
- return this.addOperation(new MergeOperation('merge'), args);
871
- }
20
+ modify(...args) {
21
+ const func = args[0];
22
+ if (!func) {
23
+ return this;
24
+ }
25
+ if (args.length === 1) {
26
+ func.call(this, this);
27
+ }
28
+ else {
29
+ args[0] = this;
30
+ func(...args);
31
+ }
32
+ return this;
33
+ }
34
+ transacting(trx) {
35
+ this._context.knex = trx || null;
36
+ return this;
37
+ }
38
+ select(...args) {
39
+ return this.addOperation(new SelectOperation('select'), args);
40
+ }
41
+ insert(...args) {
42
+ return this.addOperation(new KnexOperation('insert'), args);
43
+ }
44
+ update(...args) {
45
+ return this.addOperation(new KnexOperation('update'), args);
46
+ }
47
+ delete(...args) {
48
+ return this.addOperation(new KnexOperation('delete'), args);
49
+ }
50
+ del(...args) {
51
+ return this.delete(...args);
52
+ }
53
+ forUpdate(...args) {
54
+ return this.addOperation(new KnexOperation('forUpdate'), args);
55
+ }
56
+ forShare(...args) {
57
+ return this.addOperation(new KnexOperation('forShare'), args);
58
+ }
59
+ forNoKeyUpdate(...args) {
60
+ return this.addOperation(new KnexOperation('forNoKeyUpdate'), args);
61
+ }
62
+ forKeyShare(...args) {
63
+ return this.addOperation(new KnexOperation('forKeyShare'), args);
64
+ }
65
+ skipLocked(...args) {
66
+ return this.addOperation(new KnexOperation('skipLocked'), args);
67
+ }
68
+ noWait(...args) {
69
+ return this.addOperation(new KnexOperation('noWait'), args);
70
+ }
71
+ as(...args) {
72
+ return this.addOperation(new KnexOperation('as'), args);
73
+ }
74
+ columns(...args) {
75
+ return this.addOperation(new SelectOperation('columns'), args);
76
+ }
77
+ column(...args) {
78
+ return this.addOperation(new SelectOperation('column'), args);
79
+ }
80
+ from(...args) {
81
+ return this.addOperation(new KnexOperation('from'), args);
82
+ }
83
+ fromJS(...args) {
84
+ return this.addOperation(new KnexOperation('fromJS'), args);
85
+ }
86
+ fromRaw(...args) {
87
+ return this.addOperation(new KnexOperation('fromRaw'), args);
88
+ }
89
+ into(...args) {
90
+ return this.addOperation(new KnexOperation('into'), args);
91
+ }
92
+ withSchema(...args) {
93
+ return this.addOperation(new KnexOperation('withSchema'), args);
94
+ }
95
+ table(...args) {
96
+ return this.addOperation(new KnexOperation('table'), args);
97
+ }
98
+ distinct(...args) {
99
+ return this.addOperation(new SelectOperation('distinct'), args);
100
+ }
101
+ distinctOn(...args) {
102
+ return this.addOperation(new SelectOperation('distinctOn'), args);
103
+ }
104
+ join(...args) {
105
+ return this.addOperation(new KnexOperation('join'), args);
106
+ }
107
+ joinRaw(...args) {
108
+ return this.addOperation(new KnexOperation('joinRaw'), args);
109
+ }
110
+ innerJoin(...args) {
111
+ return this.addOperation(new KnexOperation('innerJoin'), args);
112
+ }
113
+ leftJoin(...args) {
114
+ return this.addOperation(new KnexOperation('leftJoin'), args);
115
+ }
116
+ leftOuterJoin(...args) {
117
+ return this.addOperation(new KnexOperation('leftOuterJoin'), args);
118
+ }
119
+ rightJoin(...args) {
120
+ return this.addOperation(new KnexOperation('rightJoin'), args);
121
+ }
122
+ rightOuterJoin(...args) {
123
+ return this.addOperation(new KnexOperation('rightOuterJoin'), args);
124
+ }
125
+ outerJoin(...args) {
126
+ return this.addOperation(new KnexOperation('outerJoin'), args);
127
+ }
128
+ fullOuterJoin(...args) {
129
+ return this.addOperation(new KnexOperation('fullOuterJoin'), args);
130
+ }
131
+ crossJoin(...args) {
132
+ return this.addOperation(new KnexOperation('crossJoin'), args);
133
+ }
134
+ where(...args) {
135
+ return this.addOperation(new KnexOperation('where'), args);
136
+ }
137
+ andWhere(...args) {
138
+ return this.addOperation(new KnexOperation('andWhere'), args);
139
+ }
140
+ orWhere(...args) {
141
+ return this.addOperation(new KnexOperation('orWhere'), args);
142
+ }
143
+ whereNot(...args) {
144
+ return this.addOperation(new KnexOperation('whereNot'), args);
145
+ }
146
+ andWhereNot(...args) {
147
+ return this.addOperation(new KnexOperation('andWhereNot'), args);
148
+ }
149
+ orWhereNot(...args) {
150
+ return this.addOperation(new KnexOperation('orWhereNot'), args);
151
+ }
152
+ // Makes the query match no rows.
153
+ none() {
154
+ return this.where(expression('(1 = 0)', []));
155
+ }
156
+ whereRaw(...args) {
157
+ return this.addOperation(new KnexOperation('whereRaw'), args);
158
+ }
159
+ andWhereRaw(...args) {
160
+ return this.addOperation(new KnexOperation('andWhereRaw'), args);
161
+ }
162
+ orWhereRaw(...args) {
163
+ return this.addOperation(new KnexOperation('orWhereRaw'), args);
164
+ }
165
+ whereWrapped(...args) {
166
+ return this.addOperation(new KnexOperation('whereWrapped'), args);
167
+ }
168
+ havingWrapped(...args) {
169
+ return this.addOperation(new KnexOperation('havingWrapped'), args);
170
+ }
171
+ whereExists(...args) {
172
+ return this.addOperation(new KnexOperation('whereExists'), args);
173
+ }
174
+ orWhereExists(...args) {
175
+ return this.addOperation(new KnexOperation('orWhereExists'), args);
176
+ }
177
+ whereNotExists(...args) {
178
+ return this.addOperation(new KnexOperation('whereNotExists'), args);
179
+ }
180
+ orWhereNotExists(...args) {
181
+ return this.addOperation(new KnexOperation('orWhereNotExists'), args);
182
+ }
183
+ whereIn(...args) {
184
+ return this.addOperation(new KnexOperation('whereIn'), args);
185
+ }
186
+ orWhereIn(...args) {
187
+ return this.addOperation(new KnexOperation('orWhereIn'), args);
188
+ }
189
+ whereNotIn(...args) {
190
+ return this.addOperation(new KnexOperation('whereNotIn'), args);
191
+ }
192
+ orWhereNotIn(...args) {
193
+ return this.addOperation(new KnexOperation('orWhereNotIn'), args);
194
+ }
195
+ whereNull(...args) {
196
+ return this.addOperation(new KnexOperation('whereNull'), args);
197
+ }
198
+ orWhereNull(...args) {
199
+ return this.addOperation(new KnexOperation('orWhereNull'), args);
200
+ }
201
+ whereNotNull(...args) {
202
+ return this.addOperation(new KnexOperation('whereNotNull'), args);
203
+ }
204
+ orWhereNotNull(...args) {
205
+ return this.addOperation(new KnexOperation('orWhereNotNull'), args);
206
+ }
207
+ whereBetween(...args) {
208
+ return this.addOperation(new KnexOperation('whereBetween'), args);
209
+ }
210
+ andWhereBetween(...args) {
211
+ return this.addOperation(new KnexOperation('andWhereBetween'), args);
212
+ }
213
+ whereNotBetween(...args) {
214
+ return this.addOperation(new KnexOperation('whereNotBetween'), args);
215
+ }
216
+ andWhereNotBetween(...args) {
217
+ return this.addOperation(new KnexOperation('andWhereNotBetween'), args);
218
+ }
219
+ orWhereBetween(...args) {
220
+ return this.addOperation(new KnexOperation('orWhereBetween'), args);
221
+ }
222
+ orWhereNotBetween(...args) {
223
+ return this.addOperation(new KnexOperation('orWhereNotBetween'), args);
224
+ }
225
+ whereLike(...args) {
226
+ return this.addOperation(new KnexOperation('whereLike'), args);
227
+ }
228
+ andWhereLike(...args) {
229
+ return this.addOperation(new KnexOperation('andWhereLike'), args);
230
+ }
231
+ orWhereLike(...args) {
232
+ return this.addOperation(new KnexOperation('orWhereLike'), args);
233
+ }
234
+ whereILike(...args) {
235
+ return this.addOperation(new KnexOperation('whereILike'), args);
236
+ }
237
+ andWhereILike(...args) {
238
+ return this.addOperation(new KnexOperation('andWhereILike'), args);
239
+ }
240
+ orWhereILike(...args) {
241
+ return this.addOperation(new KnexOperation('orWhereILike'), args);
242
+ }
243
+ groupBy(...args) {
244
+ return this.addOperation(new KnexOperation('groupBy'), args);
245
+ }
246
+ groupByRaw(...args) {
247
+ return this.addOperation(new KnexOperation('groupByRaw'), args);
248
+ }
249
+ orderBy(...args) {
250
+ return this.addOperation(new KnexOperation('orderBy'), args);
251
+ }
252
+ orderByRaw(...args) {
253
+ return this.addOperation(new KnexOperation('orderByRaw'), args);
254
+ }
255
+ union(...args) {
256
+ return this.addOperation(new KnexOperation('union'), args);
257
+ }
258
+ unionAll(...args) {
259
+ return this.addOperation(new KnexOperation('unionAll'), args);
260
+ }
261
+ intersect(...args) {
262
+ return this.addOperation(new KnexOperation('intersect'), args);
263
+ }
264
+ except(...args) {
265
+ return this.addOperation(new KnexOperation('except'), args);
266
+ }
267
+ having(...args) {
268
+ return this.addOperation(new KnexOperation('having'), args);
269
+ }
270
+ // Like clearSelect() and clearWhere(), these remove the operations, so that
271
+ // has() and copyFrom() see the query as it is.
272
+ clearHaving() {
273
+ return this.clear(HavingSelector);
274
+ }
275
+ clearGroup() {
276
+ return this.clear(GroupBySelector);
277
+ }
278
+ orHaving(...args) {
279
+ return this.addOperation(new KnexOperation('orHaving'), args);
280
+ }
281
+ havingIn(...args) {
282
+ return this.addOperation(new KnexOperation('havingIn'), args);
283
+ }
284
+ orHavingIn(...args) {
285
+ return this.addOperation(new KnexOperation('orHavingIn'), args);
286
+ }
287
+ havingNotIn(...args) {
288
+ return this.addOperation(new KnexOperation('havingNotIn'), args);
289
+ }
290
+ orHavingNotIn(...args) {
291
+ return this.addOperation(new KnexOperation('orHavingNotIn'), args);
292
+ }
293
+ havingNull(...args) {
294
+ return this.addOperation(new KnexOperation('havingNull'), args);
295
+ }
296
+ orHavingNull(...args) {
297
+ return this.addOperation(new KnexOperation('orHavingNull'), args);
298
+ }
299
+ havingNotNull(...args) {
300
+ return this.addOperation(new KnexOperation('havingNotNull'), args);
301
+ }
302
+ orHavingNotNull(...args) {
303
+ return this.addOperation(new KnexOperation('orHavingNotNull'), args);
304
+ }
305
+ havingExists(...args) {
306
+ return this.addOperation(new KnexOperation('havingExists'), args);
307
+ }
308
+ orHavingExists(...args) {
309
+ return this.addOperation(new KnexOperation('orHavingExists'), args);
310
+ }
311
+ havingNotExists(...args) {
312
+ return this.addOperation(new KnexOperation('havingNotExists'), args);
313
+ }
314
+ orHavingNotExists(...args) {
315
+ return this.addOperation(new KnexOperation('orHavingNotExists'), args);
316
+ }
317
+ havingBetween(...args) {
318
+ return this.addOperation(new KnexOperation('havingBetween'), args);
319
+ }
320
+ orHavingBetween(...args) {
321
+ return this.addOperation(new KnexOperation('orHavingBetween'), args);
322
+ }
323
+ havingNotBetween(...args) {
324
+ return this.addOperation(new KnexOperation('havingNotBetween'), args);
325
+ }
326
+ orHavingNotBetween(...args) {
327
+ return this.addOperation(new KnexOperation('orHavingNotBetween'), args);
328
+ }
329
+ andHaving(...args) {
330
+ return this.addOperation(new KnexOperation('andHaving'), args);
331
+ }
332
+ andHavingIn(...args) {
333
+ return this.addOperation(new KnexOperation('andHavingIn'), args);
334
+ }
335
+ andHavingNotIn(...args) {
336
+ return this.addOperation(new KnexOperation('andHavingNotIn'), args);
337
+ }
338
+ andHavingNull(...args) {
339
+ return this.addOperation(new KnexOperation('andHavingNull'), args);
340
+ }
341
+ andHavingNotNull(...args) {
342
+ return this.addOperation(new KnexOperation('andHavingNotNull'), args);
343
+ }
344
+ andHavingExists(...args) {
345
+ return this.addOperation(new KnexOperation('andHavingExists'), args);
346
+ }
347
+ andHavingNotExists(...args) {
348
+ return this.addOperation(new KnexOperation('andHavingNotExists'), args);
349
+ }
350
+ andHavingBetween(...args) {
351
+ return this.addOperation(new KnexOperation('andHavingBetween'), args);
352
+ }
353
+ andHavingNotBetween(...args) {
354
+ return this.addOperation(new KnexOperation('andHavingNotBetween'), args);
355
+ }
356
+ comment(...args) {
357
+ return this.addOperation(new KnexOperation('comment'), args);
358
+ }
359
+ hintComment(...args) {
360
+ return this.addOperation(new KnexOperation('hintComment'), args);
361
+ }
362
+ using(...args) {
363
+ return this.addOperation(new KnexOperation('using'), args);
364
+ }
365
+ havingRaw(...args) {
366
+ return this.addOperation(new KnexOperation('havingRaw'), args);
367
+ }
368
+ orHavingRaw(...args) {
369
+ return this.addOperation(new KnexOperation('orHavingRaw'), args);
370
+ }
371
+ offset(...args) {
372
+ return this.addOperation(new KnexOperation('offset'), args);
373
+ }
374
+ limit(...args) {
375
+ return this.addOperation(new KnexOperation('limit'), args);
376
+ }
377
+ count(...args) {
378
+ return this.addOperation(new SelectOperation('count'), args);
379
+ }
380
+ countDistinct(...args) {
381
+ return this.addOperation(new SelectOperation('countDistinct'), args);
382
+ }
383
+ min(...args) {
384
+ return this.addOperation(new SelectOperation('min'), args);
385
+ }
386
+ max(...args) {
387
+ return this.addOperation(new SelectOperation('max'), args);
388
+ }
389
+ sum(...args) {
390
+ return this.addOperation(new SelectOperation('sum'), args);
391
+ }
392
+ sumDistinct(...args) {
393
+ return this.addOperation(new SelectOperation('sumDistinct'), args);
394
+ }
395
+ avg(...args) {
396
+ return this.addOperation(new SelectOperation('avg'), args);
397
+ }
398
+ avgDistinct(...args) {
399
+ return this.addOperation(new SelectOperation('avgDistinct'), args);
400
+ }
401
+ debug(...args) {
402
+ return this.addOperation(new KnexOperation('debug'), args);
403
+ }
404
+ returning(...args) {
405
+ return this.addOperation(new ReturningOperation('returning'), args);
406
+ }
407
+ truncate(...args) {
408
+ return this.addOperation(new KnexOperation('truncate'), args);
409
+ }
410
+ connection(...args) {
411
+ return this.addOperation(new KnexOperation('connection'), args);
412
+ }
413
+ options(...args) {
414
+ return this.addOperation(new KnexOperation('options'), args);
415
+ }
416
+ columnInfo(...args) {
417
+ return this.addOperation(new KnexOperation('columnInfo'), args);
418
+ }
419
+ off(...args) {
420
+ return this.addOperation(new KnexOperation('off'), args);
421
+ }
422
+ timeout(...args) {
423
+ return this.addOperation(new KnexOperation('timeout'), args);
424
+ }
425
+ with(...args) {
426
+ return this.addOperation(new KnexOperation('with'), args);
427
+ }
428
+ withWrapped(...args) {
429
+ return this.addOperation(new KnexOperation('withWrapped'), args);
430
+ }
431
+ withRecursive(...args) {
432
+ return this.addOperation(new KnexOperation('withRecursive'), args);
433
+ }
434
+ withMaterialized(...args) {
435
+ return this.addOperation(new KnexOperation('withMaterialized'), args);
436
+ }
437
+ withNotMaterialized(...args) {
438
+ return this.addOperation(new KnexOperation('withNotMaterialized'), args);
439
+ }
440
+ whereComposite(...args) {
441
+ return this.addOperation(new WhereCompositeOperation('whereComposite'), args);
442
+ }
443
+ whereInComposite(...args) {
444
+ let operation = null;
445
+ if (isSqlite(this.knex())) {
446
+ operation = new WhereInCompositeSqliteOperation('whereInComposite');
447
+ }
448
+ else if (isMsSql(this.knex())) {
449
+ operation = new WhereInCompositeMsSqlOperation('whereInComposite');
450
+ }
451
+ else {
452
+ operation = new WhereInCompositeOperation('whereInComposite');
453
+ }
454
+ return this.addOperation(operation, args);
455
+ }
456
+ whereNotInComposite(...args) {
457
+ let operation = null;
458
+ if (isSqlite(this.knex())) {
459
+ operation = new WhereInCompositeSqliteOperation('whereNotInComposite', { prefix: 'not' });
460
+ }
461
+ else if (isMsSql(this.knex())) {
462
+ operation = new WhereInCompositeMsSqlOperation('whereNotInComposite', { prefix: 'not' });
463
+ }
464
+ else {
465
+ operation = new WhereInCompositeOperation('whereNotInComposite', { prefix: 'not' });
466
+ }
467
+ return this.addOperation(operation, args);
468
+ }
469
+ jsonExtract(...args) {
470
+ return this.addOperation(new KnexOperation('jsonExtract'), args);
471
+ }
472
+ jsonSet(...args) {
473
+ return this.addOperation(new KnexOperation('jsonSet'), args);
474
+ }
475
+ jsonInsert(...args) {
476
+ return this.addOperation(new KnexOperation('jsonInsert'), args);
477
+ }
478
+ jsonRemove(...args) {
479
+ return this.addOperation(new KnexOperation('jsonRemove'), args);
480
+ }
481
+ whereJsonObject(...args) {
482
+ return this.addOperation(new KnexOperation('whereJsonObject'), args);
483
+ }
484
+ orWhereJsonObject(...args) {
485
+ return this.addOperation(new KnexOperation('orWhereJsonObject'), args);
486
+ }
487
+ andWhereJsonObject(...args) {
488
+ return this.addOperation(new KnexOperation('andWhereJsonObject'), args);
489
+ }
490
+ whereNotJsonObject(...args) {
491
+ return this.addOperation(new KnexOperation('whereNotJsonObject'), args);
492
+ }
493
+ orWhereNotJsonObject(...args) {
494
+ return this.addOperation(new KnexOperation('orWhereNotJsonObject'), args);
495
+ }
496
+ andWhereNotJsonObject(...args) {
497
+ return this.addOperation(new KnexOperation('andWhereNotJsonObject'), args);
498
+ }
499
+ whereJsonPath(...args) {
500
+ return this.addOperation(new KnexOperation('whereJsonPath'), args);
501
+ }
502
+ orWhereJsonPath(...args) {
503
+ return this.addOperation(new KnexOperation('orWhereJsonPath'), args);
504
+ }
505
+ andWhereJsonPath(...args) {
506
+ return this.addOperation(new KnexOperation('andWhereJsonPath'), args);
507
+ }
508
+ // whereJson(Not)SupersetOf / whereJson(Not)SubsetOf are now supported by knex >= 1.0, but for now
509
+ // objection handles them differently and only for postgres.
510
+ // Changing them to utilize knex methods directly may require a major version bump and upgrade guide.
511
+ whereJsonSupersetOf(...args) {
512
+ return this.addOperation(new WhereJsonOperation('whereJsonSupersetOf', { operator: '@>', bool: 'and' }), args);
513
+ }
514
+ andWhereJsonSupersetOf(...args) {
515
+ return this.whereJsonSupersetOf(...args);
516
+ }
517
+ orWhereJsonSupersetOf(...args) {
518
+ return this.addOperation(new WhereJsonOperation('orWhereJsonSupersetOf', { operator: '@>', bool: 'or' }), args);
519
+ }
520
+ whereJsonNotSupersetOf(...args) {
521
+ return this.addOperation(new WhereJsonOperation('whereJsonNotSupersetOf', {
522
+ operator: '@>',
523
+ bool: 'and',
524
+ prefix: 'not',
525
+ }), args);
526
+ }
527
+ andWhereJsonNotSupersetOf(...args) {
528
+ return this.whereJsonNotSupersetOf(...args);
529
+ }
530
+ orWhereJsonNotSupersetOf(...args) {
531
+ return this.addOperation(new WhereJsonOperation('orWhereJsonNotSupersetOf', {
532
+ operator: '@>',
533
+ bool: 'or',
534
+ prefix: 'not',
535
+ }), args);
536
+ }
537
+ whereJsonSubsetOf(...args) {
538
+ return this.addOperation(new WhereJsonOperation('whereJsonSubsetOf', { operator: '<@', bool: 'and' }), args);
539
+ }
540
+ andWhereJsonSubsetOf(...args) {
541
+ return this.whereJsonSubsetOf(...args);
542
+ }
543
+ orWhereJsonSubsetOf(...args) {
544
+ return this.addOperation(new WhereJsonOperation('orWhereJsonSubsetOf', { operator: '<@', bool: 'or' }), args);
545
+ }
546
+ whereJsonNotSubsetOf(...args) {
547
+ return this.addOperation(new WhereJsonOperation('whereJsonNotSubsetOf', {
548
+ operator: '<@',
549
+ bool: 'and',
550
+ prefix: 'not',
551
+ }), args);
552
+ }
553
+ andWhereJsonNotSubsetOf(...args) {
554
+ return this.whereJsonNotSubsetOf(...args);
555
+ }
556
+ orWhereJsonNotSubsetOf(...args) {
557
+ return this.addOperation(new WhereJsonOperation('orWhereJsonNotSubsetOf', {
558
+ operator: '<@',
559
+ bool: 'or',
560
+ prefix: 'not',
561
+ }), args);
562
+ }
563
+ whereJsonNotArray(...args) {
564
+ return this.addOperation(new WhereJsonNotObjectOperation('whereJsonNotArray', {
565
+ bool: 'and',
566
+ compareValue: [],
567
+ }), args);
568
+ }
569
+ orWhereJsonNotArray(...args) {
570
+ return this.addOperation(new WhereJsonNotObjectOperation('orWhereJsonNotArray', {
571
+ bool: 'or',
572
+ compareValue: [],
573
+ }), args);
574
+ }
575
+ whereJsonNotObject(...args) {
576
+ return this.addOperation(new WhereJsonNotObjectOperation('whereJsonNotObject', {
577
+ bool: 'and',
578
+ compareValue: {},
579
+ }), args);
580
+ }
581
+ orWhereJsonNotObject(...args) {
582
+ return this.addOperation(new WhereJsonNotObjectOperation('orWhereJsonNotObject', {
583
+ bool: 'or',
584
+ compareValue: {},
585
+ }), args);
586
+ }
587
+ whereJsonHasAny(...args) {
588
+ return this.addOperation(new WhereJsonHasOperation('whereJsonHasAny', { bool: 'and', operator: '?|' }), args);
589
+ }
590
+ orWhereJsonHasAny(...args) {
591
+ return this.addOperation(new WhereJsonHasOperation('orWhereJsonHasAny', { bool: 'or', operator: '?|' }), args);
592
+ }
593
+ whereJsonHasAll(...args) {
594
+ return this.addOperation(new WhereJsonHasOperation('whereJsonHasAll', { bool: 'and', operator: '?&' }), args);
595
+ }
596
+ orWhereJsonHasAll(...args) {
597
+ return this.addOperation(new WhereJsonHasOperation('orWhereJsonHasAll', { bool: 'or', operator: '?&' }), args);
598
+ }
599
+ whereJsonOverlaps(...args) {
600
+ return this.addOperation(new WhereJsonOverlapsOperation('whereJsonOverlaps', { bool: 'and' }), args);
601
+ }
602
+ andWhereJsonOverlaps(...args) {
603
+ return this.whereJsonOverlaps(...args);
604
+ }
605
+ orWhereJsonOverlaps(...args) {
606
+ return this.addOperation(new WhereJsonOverlapsOperation('orWhereJsonOverlaps', { bool: 'or' }), args);
607
+ }
608
+ whereJsonNotOverlaps(...args) {
609
+ return this.addOperation(new WhereJsonOverlapsOperation('whereJsonNotOverlaps', { bool: 'and', prefix: 'not' }), args);
610
+ }
611
+ andWhereJsonNotOverlaps(...args) {
612
+ return this.whereJsonNotOverlaps(...args);
613
+ }
614
+ orWhereJsonNotOverlaps(...args) {
615
+ return this.addOperation(new WhereJsonOverlapsOperation('orWhereJsonNotOverlaps', { bool: 'or', prefix: 'not' }), args);
616
+ }
617
+ whereJsonIsArray(fieldExpression) {
618
+ return this.whereJsonSupersetOf(fieldExpression, []);
619
+ }
620
+ orWhereJsonIsArray(fieldExpression) {
621
+ return this.orWhereJsonSupersetOf(fieldExpression, []);
622
+ }
623
+ whereJsonIsObject(fieldExpression) {
624
+ return this.whereJsonSupersetOf(fieldExpression, {});
625
+ }
626
+ orWhereJsonIsObject(fieldExpression) {
627
+ return this.orWhereJsonSupersetOf(fieldExpression, {});
628
+ }
629
+ whereColumn(...args) {
630
+ return this.addOperation(new KnexOperation('whereColumn'), args);
631
+ }
632
+ andWhereColumn(...args) {
633
+ return this.addOperation(new KnexOperation('andWhereColumn'), args);
634
+ }
635
+ orWhereColumn(...args) {
636
+ return this.addOperation(new KnexOperation('orWhereColumn'), args);
637
+ }
638
+ whereNotColumn(...args) {
639
+ return this.addOperation(new KnexOperation('whereNotColumn'), args);
640
+ }
641
+ andWhereNotColumn(...args) {
642
+ return this.addOperation(new KnexOperation('andWhereNotColumn'), args);
643
+ }
644
+ orWhereNotColumn(...args) {
645
+ return this.addOperation(new KnexOperation('orWhereNotColumn'), args);
646
+ }
647
+ onConflict(...args) {
648
+ return this.addOperation(new KnexOperation('onConflict'), args);
649
+ }
650
+ ignore(...args) {
651
+ return this.addOperation(new KnexOperation('ignore'), args);
652
+ }
653
+ merge(...args) {
654
+ return this.addOperation(new MergeOperation('merge'), args);
655
+ }
872
656
  }
873
-
874
657
  Object.defineProperties(QueryBuilderBase.prototype, {
875
- isObjectionQueryBuilderBase: {
876
- enumerable: false,
877
- writable: false,
878
- value: true,
879
- },
658
+ isObjectionQueryBuilderBase: {
659
+ enumerable: false,
660
+ writable: false,
661
+ value: true,
662
+ },
880
663
  });
881
-
882
664
  module.exports = {
883
- QueryBuilderBase,
665
+ QueryBuilderBase,
884
666
  };