Spaces:
Runtime error
Runtime error
File size: 623 Bytes
4f2c36e cca515d 848e268 7e19cbb 5881efa cca515d 848e268 5881efa 4f2c36e 7e19cbb 848e268 7e19cbb 848e268 4f2c36e |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
import { PrismaClient } from '@prisma/client'
const prisma = new PrismaClient()
export async function POST(request: Request) {
const { ids, page } = await request.json()
const collections = await prisma.collection.findMany({
orderBy: {
id: 'desc'
},
where: {
id: {
in: ids,
}
},
take: 15,
skip: page * 15
})
const total = await prisma.collection.count()
return Response.json(
{
collections,
pagination: {
total,
page: page + 1,
total_pages: Math.ceil(total / 15)
},
status: 200,
ok: true
}
)
} |