added OrderBy functionality to Data Table
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user