|
|
@ -419,8 +419,11 @@ class BaseModelSqlv2 { |
|
|
|
// if autogenerated string sort by created_at column if present
|
|
|
|
// if autogenerated string sort by created_at column if present
|
|
|
|
if (this.model.primaryKey && this.model.primaryKey.ai) { |
|
|
|
if (this.model.primaryKey && this.model.primaryKey.ai) { |
|
|
|
qb.orderBy(this.model.primaryKey.column_name); |
|
|
|
qb.orderBy(this.model.primaryKey.column_name); |
|
|
|
} else if (this.model.columns.find((c) => c.column_name === 'created_at')) { |
|
|
|
} else { |
|
|
|
qb.orderBy('created_at'); |
|
|
|
const createdCol = this.model.columns.find( |
|
|
|
|
|
|
|
(c) => c.uidt === UITypes.CreatedTime && c.system, |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
if (createdCol) qb.orderBy(createdCol.column_name); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (!ignorePagination) applyPaginate(qb, rest); |
|
|
|
if (!ignorePagination) applyPaginate(qb, rest); |
|
|
|