mirror of
https://github.com/stefanpejcic/openpanel
synced 2025-06-26 18:28:26 +00:00
packages
This commit is contained in:
21
packages/appwrite/src/utils/getAppwriteSorting.ts
Normal file
21
packages/appwrite/src/utils/getAppwriteSorting.ts
Normal file
@@ -0,0 +1,21 @@
|
||||
import type { 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;
|
||||
};
|
||||
Reference in New Issue
Block a user