pg-mvc-service 2.0.101 → 2.0.102
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.
- package/dist/models/TableModel.js +14 -11
- package/package.json +1 -1
- package/src/models/TableModel.ts +15 -11
|
@@ -241,13 +241,16 @@ class TableModel {
|
|
|
241
241
|
join(joinType, joinModel, conditions) {
|
|
242
242
|
this.joinConditions.push({ type: joinType, model: joinModel, conditions: conditions });
|
|
243
243
|
}
|
|
244
|
-
where(
|
|
245
|
-
if (typeof
|
|
246
|
-
if (
|
|
247
|
-
this.whereExpressions.push(
|
|
244
|
+
where(param1, param2, right) {
|
|
245
|
+
if (typeof param1 === 'string') {
|
|
246
|
+
if (param2 === undefined || right === undefined || Array.isArray(param2)) {
|
|
247
|
+
this.whereExpressions.push(param1);
|
|
248
|
+
if (Array.isArray(param2)) {
|
|
249
|
+
this.vars = [...this.vars, ...param2];
|
|
250
|
+
}
|
|
248
251
|
}
|
|
249
252
|
else {
|
|
250
|
-
const query = WhereExpression_1.WhereExpression.create({ model: this, name:
|
|
253
|
+
const query = WhereExpression_1.WhereExpression.create({ model: this, name: param1 }, param2, right, this.vars.length + 1);
|
|
251
254
|
this.whereExpressions.push(query.expression);
|
|
252
255
|
if (query.vars !== undefined) {
|
|
253
256
|
this.vars = [...this.vars, ...query.vars];
|
|
@@ -255,12 +258,12 @@ class TableModel {
|
|
|
255
258
|
}
|
|
256
259
|
return;
|
|
257
260
|
}
|
|
258
|
-
if ('model' in
|
|
259
|
-
if (
|
|
260
|
-
throw new Error(`If left is TColumnInfo, please set operator and right.`);
|
|
261
|
+
if ('model' in param1 && 'name' in param1) {
|
|
262
|
+
if (param2 === undefined || right === undefined || Array.isArray(param2)) {
|
|
263
|
+
throw new Error(`If left is TColumnInfo, please set operator and right. Do not pass an array to operator.`);
|
|
261
264
|
}
|
|
262
265
|
else {
|
|
263
|
-
const query = WhereExpression_1.WhereExpression.create(
|
|
266
|
+
const query = WhereExpression_1.WhereExpression.create(param1, param2, right, this.vars.length + 1);
|
|
264
267
|
this.whereExpressions.push(query.expression);
|
|
265
268
|
if (query.vars !== undefined) {
|
|
266
269
|
this.vars = [...this.vars, ...query.vars];
|
|
@@ -268,8 +271,8 @@ class TableModel {
|
|
|
268
271
|
}
|
|
269
272
|
return;
|
|
270
273
|
}
|
|
271
|
-
if (Array.isArray(
|
|
272
|
-
const query = WhereExpression_1.WhereExpression.createCondition(
|
|
274
|
+
if (Array.isArray(param1)) {
|
|
275
|
+
const query = WhereExpression_1.WhereExpression.createCondition(param1, this, this.vars.length + 1);
|
|
273
276
|
this.whereExpressions.push(query.expression);
|
|
274
277
|
if (query.vars !== undefined) {
|
|
275
278
|
this.vars = [...this.vars, ...query.vars];
|
package/package.json
CHANGED
package/src/models/TableModel.ts
CHANGED
|
@@ -286,15 +286,19 @@ export class TableModel {
|
|
|
286
286
|
}
|
|
287
287
|
|
|
288
288
|
public where(expression: string): void;
|
|
289
|
+
public where(expression: string, vars: Array<any>): void;
|
|
289
290
|
public where(conditions: Array<TNestedCondition>): void;
|
|
290
291
|
public where(left: string, operator: TOperator, right: TColumnInfo | any): void;
|
|
291
292
|
public where(left: TColumnInfo, operator: TOperator, right: TColumnInfo | any): void;
|
|
292
|
-
public where(
|
|
293
|
-
if (typeof
|
|
294
|
-
if (
|
|
295
|
-
this.whereExpressions.push(
|
|
293
|
+
public where(param1: string | TColumnInfo | Array<TNestedCondition>, param2?: Array<any> | TOperator, right?: TColumnInfo | any): void {
|
|
294
|
+
if (typeof param1 === 'string') {
|
|
295
|
+
if (param2 === undefined || right === undefined || Array.isArray(param2)) {
|
|
296
|
+
this.whereExpressions.push(param1);
|
|
297
|
+
if (Array.isArray(param2)) {
|
|
298
|
+
this.vars = [...this.vars, ...param2];
|
|
299
|
+
}
|
|
296
300
|
} else {
|
|
297
|
-
const query = WhereExpression.create({model: this, name:
|
|
301
|
+
const query = WhereExpression.create({model: this, name: param1}, param2, right, this.vars.length + 1);
|
|
298
302
|
this.whereExpressions.push(query.expression);
|
|
299
303
|
if (query.vars !== undefined) {
|
|
300
304
|
this.vars = [...this.vars, ...query.vars];
|
|
@@ -303,11 +307,11 @@ export class TableModel {
|
|
|
303
307
|
return;
|
|
304
308
|
}
|
|
305
309
|
|
|
306
|
-
if ('model' in
|
|
307
|
-
if (
|
|
308
|
-
throw new Error(`If left is TColumnInfo, please set operator and right.`);
|
|
310
|
+
if ('model' in param1 && 'name' in param1) {
|
|
311
|
+
if (param2 === undefined || right === undefined || Array.isArray(param2)) {
|
|
312
|
+
throw new Error(`If left is TColumnInfo, please set operator and right. Do not pass an array to operator.`);
|
|
309
313
|
} else {
|
|
310
|
-
const query = WhereExpression.create(
|
|
314
|
+
const query = WhereExpression.create(param1, param2, right, this.vars.length + 1);
|
|
311
315
|
this.whereExpressions.push(query.expression);
|
|
312
316
|
if (query.vars !== undefined) {
|
|
313
317
|
this.vars = [...this.vars, ...query.vars];
|
|
@@ -316,8 +320,8 @@ export class TableModel {
|
|
|
316
320
|
return;
|
|
317
321
|
}
|
|
318
322
|
|
|
319
|
-
if (Array.isArray(
|
|
320
|
-
const query = WhereExpression.createCondition(
|
|
323
|
+
if (Array.isArray(param1)) {
|
|
324
|
+
const query = WhereExpression.createCondition(param1, this, this.vars.length + 1);
|
|
321
325
|
this.whereExpressions.push(query.expression);
|
|
322
326
|
if (query.vars !== undefined) {
|
|
323
327
|
this.vars = [...this.vars, ...query.vars];
|