added OrderBy functionality to Data Table

This commit is contained in:
PxlLoewe
2025-06-03 17:54:30 -07:00
parent 574472dcb9
commit 0eb3ba8104
11 changed files with 117 additions and 121 deletions

View File

@@ -1,3 +1,4 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
"use server";
import { prisma, PrismaClient } from "@repo/db";
@@ -9,6 +10,7 @@ export async function getData(
searchFields: string[],
filter?: Record<string, any>,
include?: Record<string, boolean>,
orderBy?: Record<string, "asc" | "desc">,
) {
if (!model || !prisma[model]) {
return { data: [], total: 0 };
@@ -34,6 +36,7 @@ export async function getData(
const data = await (prisma[model] as any).findMany({
where,
orderBy,
take: limit,
skip: offset,
include,