Add sorting foundation as util and using it within indexed-db-handler (#2773)

This commit is contained in:
Carlos Alcaide Corvo authored and GitHub committed 2025-05-13 16:18:04 -04:00
1 parent e96131a933
commit b0d26fe1e6
5 files changed
+594 -26

No files matched your search

+3 -8
View File
@@ -70,14 +70,9 @@ export async function queryIndexedDb(indexedDb, resource, query) {
);
}
// OrderBy has to be used on where clauses while if it's a
// collection already we have to use sortBy. We'll also sort by
// descending order based on created time to match the API as any
// "or" clause can change the order
if (filterCollection.orderBy) {
return filterCollection.orderBy(getKey('created_time')).reverse().toArray();
}
return filterCollection.reverse().sortBy(getKey('created_time'));
// filterCollection can be Dexie Table or a Dexie Collection.
// This is an important detail you need to keep in mind when working on it.
return filterCollection.toArray();
}
const buildInitialWhereClause = ({ filterArrayOrObject, table, key }) => {