chore: apply Biome cleanup
This commit is contained in:
+20
-8
@@ -1,14 +1,25 @@
|
||||
import type { Prisma } from "@/generated/prisma/client"
|
||||
import type { PaginatedResult } from "@/types"
|
||||
|
||||
type PaginationModel<T> = {
|
||||
findMany(args: {
|
||||
where?: unknown
|
||||
skip: number
|
||||
take: number
|
||||
orderBy?: unknown
|
||||
include?: unknown
|
||||
select?: unknown
|
||||
}): Promise<T[]>
|
||||
count(args: { where?: unknown }): Promise<number>
|
||||
}
|
||||
|
||||
type PaginationArgs<_T> = {
|
||||
model: any
|
||||
where?: Prisma.Enumerable<any>
|
||||
model: unknown
|
||||
where?: unknown
|
||||
page?: number
|
||||
pageSize?: number
|
||||
orderBy?: any
|
||||
include?: Prisma.Enumerable<any>
|
||||
select?: Prisma.Enumerable<any>
|
||||
orderBy?: unknown
|
||||
include?: unknown
|
||||
select?: unknown
|
||||
}
|
||||
|
||||
export async function paginate<T>({
|
||||
@@ -21,9 +32,10 @@ export async function paginate<T>({
|
||||
select,
|
||||
}: PaginationArgs<T>): Promise<PaginatedResult<T>> {
|
||||
const skip = (page - 1) * pageSize
|
||||
const paginatedModel = model as PaginationModel<T>
|
||||
|
||||
const [data, totalItems] = await Promise.all([
|
||||
model.findMany({
|
||||
paginatedModel.findMany({
|
||||
where,
|
||||
skip,
|
||||
take: pageSize,
|
||||
@@ -31,7 +43,7 @@ export async function paginate<T>({
|
||||
include,
|
||||
select,
|
||||
}),
|
||||
model.count({ where }),
|
||||
paginatedModel.count({ where }),
|
||||
])
|
||||
|
||||
return {
|
||||
|
||||
Reference in New Issue
Block a user