offset-based pagination in a field with a relation

let item = await prisma.item.findFirstOrThrow({
where: {
id: req.params.id
},
include: {
updates: {
skip: +req.params.page * pageSize || 0,
take: pageSize
}
}
});
let item = await prisma.item.findFirstOrThrow({
where: {
id: req.params.id
},
include: {
updates: {
skip: +req.params.page * pageSize || 0,
take: pageSize
}
}
});
Essentially, I have a schema with updates ItemUpdate[], and I need to fetch its updates, but i want to paginate it. i know i can just do prisma.itemUpdates.fetchMany, but I want to be able to return a 404 when the item ID is not found - and it's possible for the item to exist without any updates - and i can't check that if i'm simply using a where { itemId } in an itemUpdates call so, is this valid? ^^^
0 Replies
No replies yetBe the first to reply to this messageJoin