|
|
|
@ -119,12 +119,14 @@ class BaseModelSqlv2 {
|
|
|
|
|
args: { |
|
|
|
|
where?: string; |
|
|
|
|
filterArr?: Filter[]; |
|
|
|
|
sort?: string | string[]; |
|
|
|
|
} = {} |
|
|
|
|
): Promise<any> { |
|
|
|
|
const qb = this.dbDriver(this.model.table_name); |
|
|
|
|
await this.selectObject({ qb }); |
|
|
|
|
|
|
|
|
|
const aliasColObjMap = await this.model.getAliasColObjMap(); |
|
|
|
|
const sorts = extractSortsObject(args?.sort, aliasColObjMap); |
|
|
|
|
const filterObj = extractFilterFromXwhere(args?.where, aliasColObjMap); |
|
|
|
|
|
|
|
|
|
await conditionV2( |
|
|
|
@ -145,6 +147,12 @@ class BaseModelSqlv2 {
|
|
|
|
|
this.dbDriver |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
if (Array.isArray(sorts) && sorts?.length) { |
|
|
|
|
await sortV2(sorts, qb, this.dbDriver); |
|
|
|
|
} else if (this.model.primaryKey) { |
|
|
|
|
qb.orderBy(this.model.primaryKey.column_name); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
const data = await qb.first(); |
|
|
|
|
|
|
|
|
|
if (data) { |
|
|
|
|