Skip to content

Commit

Permalink
Merge pull request #192 from plainblack/db_sorting_duplicates
Browse files Browse the repository at this point in the history
Always fall back to sorting the list by the id, so that duplicate ent…
  • Loading branch information
rizen authored Oct 1, 2024
2 parents 2f28602 + 6f1cf33 commit 8d958d1
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion ving/record/VingRecord.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -855,12 +855,19 @@ export class VingKind {
where
) {
const sortMethod = (params.sortOrder == 'desc') ? desc : asc;
let orderBy = [sortMethod(this.table.createdAt)];
let orderBy = [sortMethod(this.table.createdAt), sortMethod(this.table.id)];
if (params.sortBy) {
const cols = [];
let hasIdSortField = false;
for (const field of params.sortBy) {
if (field == 'id') {
hasIdSortField = true;
}
cols.push(sortMethod(this.table[field]));
}
if (!hasIdSortField) {
cols.push(sortMethod(this.table.id));
}
orderBy = cols;
}
const itemsPerPage = isUndefined(params?.itemsPerPage) || params?.itemsPerPage > 100 || params?.itemsPerPage < 1 ? 10 : params.itemsPerPage;
Expand Down

0 comments on commit 8d958d1

Please sign in to comment.