|
|
|
@ -90,7 +90,7 @@ class BaseModelSqlv2 {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public async readByPk(id?: any): Promise<any> { |
|
|
|
|
const qb = this.dbDriver(this.model.table_name); |
|
|
|
|
const qb = this.dbDriver(this.tnPath); |
|
|
|
|
|
|
|
|
|
await this.selectObject({ qb }); |
|
|
|
|
|
|
|
|
@ -106,7 +106,7 @@ class BaseModelSqlv2 {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public async exist(id?: any): Promise<any> { |
|
|
|
|
const qb = this.dbDriver(this.model.table_name); |
|
|
|
|
const qb = this.dbDriver(this.tnPath); |
|
|
|
|
await this.selectObject({ qb }); |
|
|
|
|
const pks = this.model.primaryKeys; |
|
|
|
|
if ((id + '').split('___').length != pks.length) { |
|
|
|
@ -122,7 +122,7 @@ class BaseModelSqlv2 {
|
|
|
|
|
sort?: string | string[]; |
|
|
|
|
} = {} |
|
|
|
|
): Promise<any> { |
|
|
|
|
const qb = this.dbDriver(this.model.table_name); |
|
|
|
|
const qb = this.dbDriver(this.tnPath); |
|
|
|
|
await this.selectObject({ qb }); |
|
|
|
|
|
|
|
|
|
const aliasColObjMap = await this.model.getAliasColObjMap(); |
|
|
|
@ -175,15 +175,12 @@ class BaseModelSqlv2 {
|
|
|
|
|
): Promise<any> { |
|
|
|
|
const { where, ...rest } = this._getListArgs(args as any); |
|
|
|
|
|
|
|
|
|
const qb = this.dbDriver(this.model.table_name); |
|
|
|
|
const qb = this.dbDriver(this.tnPath); |
|
|
|
|
await this.selectObject({ qb }); |
|
|
|
|
|
|
|
|
|
const aliasColObjMap = await this.model.getAliasColObjMap(); |
|
|
|
|
|
|
|
|
|
let sorts = extractSortsObject(args?.sort, aliasColObjMap); |
|
|
|
|
|
|
|
|
|
const filterObj = extractFilterFromXwhere(args?.where, aliasColObjMap); |
|
|
|
|
|
|
|
|
|
// todo: replace with view id
|
|
|
|
|
if (!ignoreFilterSort && this.viewId) { |
|
|
|
|
await conditionV2( |
|
|
|
@ -249,7 +246,6 @@ class BaseModelSqlv2 {
|
|
|
|
|
|
|
|
|
|
if (!ignoreFilterSort) applyPaginate(qb, rest); |
|
|
|
|
const proto = await this.getProto(); |
|
|
|
|
|
|
|
|
|
const data = await this.extractRawQueryAndExec(qb); |
|
|
|
|
|
|
|
|
|
return data?.map(d => { |
|
|
|
@ -265,7 +261,7 @@ class BaseModelSqlv2 {
|
|
|
|
|
await this.model.getColumns(); |
|
|
|
|
const { where } = this._getListArgs(args); |
|
|
|
|
|
|
|
|
|
const qb = this.dbDriver(this.model.table_name); |
|
|
|
|
const qb = this.dbDriver(this.tnPath); |
|
|
|
|
|
|
|
|
|
// qb.xwhere(where, await this.model.getAliasColMapping());
|
|
|
|
|
const aliasColObjMap = await this.model.getAliasColObjMap(); |
|
|
|
@ -334,7 +330,7 @@ class BaseModelSqlv2 {
|
|
|
|
|
) { |
|
|
|
|
const { where, ...rest } = this._getListArgs(args as any); |
|
|
|
|
|
|
|
|
|
const qb = this.dbDriver(this.model.table_name); |
|
|
|
|
const qb = this.dbDriver(this.tnPath); |
|
|
|
|
qb.count(`${this.model.primaryKey?.column_name || '*'} as count`); |
|
|
|
|
qb.select(args.column_name); |
|
|
|
|
|
|
|
|
@ -1618,7 +1614,7 @@ class BaseModelSqlv2 {
|
|
|
|
|
} else { |
|
|
|
|
await this.model.getColumns(); |
|
|
|
|
const { where } = this._getListArgs(args); |
|
|
|
|
const qb = this.dbDriver(this.model.table_name); |
|
|
|
|
const qb = this.dbDriver(this.tnPath); |
|
|
|
|
const aliasColObjMap = await this.model.getAliasColObjMap(); |
|
|
|
|
const filterObj = extractFilterFromXwhere(where, aliasColObjMap); |
|
|
|
|
|
|
|
|
@ -1680,7 +1676,7 @@ class BaseModelSqlv2 {
|
|
|
|
|
try { |
|
|
|
|
await this.model.getColumns(); |
|
|
|
|
const { where } = this._getListArgs(args); |
|
|
|
|
const qb = this.dbDriver(this.model.table_name); |
|
|
|
|
const qb = this.dbDriver(this.tnPath); |
|
|
|
|
const aliasColObjMap = await this.model.getAliasColObjMap(); |
|
|
|
|
const filterObj = extractFilterFromXwhere(where, aliasColObjMap); |
|
|
|
|
|
|
|
|
|