|
|
|
@ -878,6 +878,14 @@ class BaseModelSqlv2 {
|
|
|
|
|
const filterObj = extractFilterFromXwhere(where, aliasColObjMap); |
|
|
|
|
await conditionV2(filterObj, qb, this.dbDriver); |
|
|
|
|
|
|
|
|
|
// sort by primary key if not autogenerated string
|
|
|
|
|
// if autogenerated string sort by created_at column if present
|
|
|
|
|
if (childTable.primaryKey && childTable.primaryKey.ai) { |
|
|
|
|
qb.orderBy(childTable.primaryKey.column_name); |
|
|
|
|
} else if (childTable.columns.find((c) => c.column_name === 'created_at')) { |
|
|
|
|
qb.orderBy('created_at'); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
applyPaginate(qb, rest); |
|
|
|
|
|
|
|
|
|
const proto = await childModel.getProto(); |
|
|
|
@ -978,6 +986,14 @@ class BaseModelSqlv2 {
|
|
|
|
|
const filterObj = extractFilterFromXwhere(where, aliasColObjMap); |
|
|
|
|
await conditionV2(filterObj, qb, this.dbDriver); |
|
|
|
|
|
|
|
|
|
// sort by primary key if not autogenerated string
|
|
|
|
|
// if autogenerated string sort by created_at column if present
|
|
|
|
|
if (childTable.primaryKey && childTable.primaryKey.ai) { |
|
|
|
|
qb.orderBy(childTable.primaryKey.column_name); |
|
|
|
|
} else if (childTable.columns.find((c) => c.column_name === 'created_at')) { |
|
|
|
|
qb.orderBy('created_at'); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
applyPaginate(qb, rest); |
|
|
|
|
|
|
|
|
|
const proto = await childModel.getProto(); |
|
|
|
@ -1079,6 +1095,16 @@ class BaseModelSqlv2 {
|
|
|
|
|
const filterObj = extractFilterFromXwhere(where, aliasColObjMap); |
|
|
|
|
await conditionV2(filterObj, qb, this.dbDriver); |
|
|
|
|
|
|
|
|
|
// sort by primary key if not autogenerated string
|
|
|
|
|
// if autogenerated string sort by created_at column if present
|
|
|
|
|
if (parentTable.primaryKey && parentTable.primaryKey.ai) { |
|
|
|
|
qb.orderBy(parentTable.primaryKey.column_name); |
|
|
|
|
} else if ( |
|
|
|
|
parentTable.columns.find((c) => c.column_name === 'created_at') |
|
|
|
|
) { |
|
|
|
|
qb.orderBy('created_at'); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
applyPaginate(qb, rest); |
|
|
|
|
|
|
|
|
|
const proto = await parentModel.getProto(); |
|
|
|
|