|
|
@ -141,9 +141,11 @@ class BaseModelSqlv2 { |
|
|
|
{ |
|
|
|
{ |
|
|
|
ignoreView = false, |
|
|
|
ignoreView = false, |
|
|
|
getHiddenColumn = false, |
|
|
|
getHiddenColumn = false, |
|
|
|
|
|
|
|
throwErrorIfInvalidParams = false, |
|
|
|
}: { |
|
|
|
}: { |
|
|
|
ignoreView?: boolean; |
|
|
|
ignoreView?: boolean; |
|
|
|
getHiddenColumn?: boolean; |
|
|
|
getHiddenColumn?: boolean; |
|
|
|
|
|
|
|
throwErrorIfInvalidParams?: boolean; |
|
|
|
} = {}, |
|
|
|
} = {}, |
|
|
|
): Promise<any> { |
|
|
|
): Promise<any> { |
|
|
|
const qb = this.dbDriver(this.tnPath); |
|
|
|
const qb = this.dbDriver(this.tnPath); |
|
|
@ -153,6 +155,7 @@ class BaseModelSqlv2 { |
|
|
|
model: this.model, |
|
|
|
model: this.model, |
|
|
|
view: ignoreView ? null : this.viewId && (await View.get(this.viewId)), |
|
|
|
view: ignoreView ? null : this.viewId && (await View.get(this.viewId)), |
|
|
|
getHiddenColumn, |
|
|
|
getHiddenColumn, |
|
|
|
|
|
|
|
throwErrorIfInvalidParams |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
await this.selectObject({ |
|
|
|
await this.selectObject({ |
|
|
@ -369,6 +372,7 @@ class BaseModelSqlv2 { |
|
|
|
public async count( |
|
|
|
public async count( |
|
|
|
args: { where?: string; limit?; filterArr?: Filter[] } = {}, |
|
|
|
args: { where?: string; limit?; filterArr?: Filter[] } = {}, |
|
|
|
ignoreViewFilterAndSort = false, |
|
|
|
ignoreViewFilterAndSort = false, |
|
|
|
|
|
|
|
throwErrorIfInvalidParams = false, |
|
|
|
): Promise<any> { |
|
|
|
): Promise<any> { |
|
|
|
await this.model.getColumns(); |
|
|
|
await this.model.getColumns(); |
|
|
|
const { where } = this._getListArgs(args); |
|
|
|
const { where } = this._getListArgs(args); |
|
|
@ -377,7 +381,7 @@ class BaseModelSqlv2 { |
|
|
|
|
|
|
|
|
|
|
|
// qb.xwhere(where, await this.model.getAliasColMapping());
|
|
|
|
// qb.xwhere(where, await this.model.getAliasColMapping());
|
|
|
|
const aliasColObjMap = await this.model.getAliasColObjMap(); |
|
|
|
const aliasColObjMap = await this.model.getAliasColObjMap(); |
|
|
|
const filterObj = extractFilterFromXwhere(where, aliasColObjMap); |
|
|
|
const filterObj = extractFilterFromXwhere(where, aliasColObjMap,throwErrorIfInvalidParams); |
|
|
|
|
|
|
|
|
|
|
|
if (!ignoreViewFilterAndSort && this.viewId) { |
|
|
|
if (!ignoreViewFilterAndSort && this.viewId) { |
|
|
|
await conditionV2( |
|
|
|
await conditionV2( |
|
|
@ -401,6 +405,8 @@ class BaseModelSqlv2 { |
|
|
|
...(args.filterArr || []), |
|
|
|
...(args.filterArr || []), |
|
|
|
], |
|
|
|
], |
|
|
|
qb, |
|
|
|
qb, |
|
|
|
|
|
|
|
undefined, |
|
|
|
|
|
|
|
throwErrorIfInvalidParams |
|
|
|
); |
|
|
|
); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
await conditionV2( |
|
|
|
await conditionV2( |
|
|
@ -419,6 +425,8 @@ class BaseModelSqlv2 { |
|
|
|
...(args.filterArr || []), |
|
|
|
...(args.filterArr || []), |
|
|
|
], |
|
|
|
], |
|
|
|
qb, |
|
|
|
qb, |
|
|
|
|
|
|
|
undefined, |
|
|
|
|
|
|
|
throwErrorIfInvalidParams |
|
|
|
); |
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|