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.
@@ -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(left, operator, right) {
245
- if (typeof left === 'string') {
246
- if (operator === undefined || right === undefined) {
247
- this.whereExpressions.push(left);
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: left }, operator, right, this.vars.length + 1);
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 left && 'name' in left) {
259
- if (operator === undefined || right === undefined) {
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(left, operator, right, this.vars.length + 1);
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(left)) {
272
- const query = WhereExpression_1.WhereExpression.createCondition(left, this, this.vars.length + 1);
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pg-mvc-service",
3
- "version": "2.0.101",
3
+ "version": "2.0.102",
4
4
  "description": "",
5
5
  "homepage": "https://github.com/n-daira/npm-pack_mvc-service#readme",
6
6
  "bugs": {
@@ -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(left: string | TColumnInfo | Array<TNestedCondition>, operator?: TOperator, right?: TColumnInfo | any): void {
293
- if (typeof left === 'string') {
294
- if (operator === undefined || right === undefined) {
295
- this.whereExpressions.push(left);
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: left}, operator, right, this.vars.length + 1);
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 left && 'name' in left) {
307
- if (operator === undefined || right === undefined) {
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(left, operator, right, this.vars.length + 1);
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(left)) {
320
- const query = WhereExpression.createCondition(left, this, this.vars.length + 1);
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];