This commit is contained in:
Stefan Pejcic
2024-05-08 19:58:53 +02:00
parent 440d98beff
commit 8595a9f4e5
2479 changed files with 591504 additions and 0 deletions

View File

@@ -0,0 +1,23 @@
import { CrudSorting } from "@refinedev/core";
import { Query } from "appwrite";
type GetAppwriteSortingType = {
(sorts?: CrudSorting): string[];
};
export const getAppwriteSorting: GetAppwriteSortingType = (sorters) => {
const sorts: string[] = [];
if (sorters) {
sorters.map((item) => {
const field = item.field === "id" ? "$id" : item.field;
if (item.order === "asc") {
sorts.push(Query.orderAsc(field));
} else {
sorts.push(Query.orderDesc(field));
}
});
}
return sorts;
};