Cursor based paging issue for multilevel relationships
I have this query. As you can see my paging field's like cursors are inside the select: works section. Question completes in the next post.
const works = await this.#client.follow.findMany({
select: {
followed: {
select: {
works: {
take: pageSize,
skip: lastCursor ? 1 : 0,
cursor: lastCursor
? {
id: lastCursor,
}
: undefined,
orderBy: {
id: SortOrder.Desc,
},
select: {
id: true,
updatedAt: true,
title: true,
description: true,
content: true,
authorId: true,
author: {
select: {
userName: true,
fullName: true,
description: true,
},
},
workTopics: {
select: {
topic: {
select: {
id: true,
name: true,
},
},
},
},
workLikes: {
select: {
id: true,
},
},
},
},
},
},
},
where: {
followerId,
},
});const works = await this.#client.follow.findMany({
select: {
followed: {
select: {
works: {
take: pageSize,
skip: lastCursor ? 1 : 0,
cursor: lastCursor
? {
id: lastCursor,
}
: undefined,
orderBy: {
id: SortOrder.Desc,
},
select: {
id: true,
updatedAt: true,
title: true,
description: true,
content: true,
authorId: true,
author: {
select: {
userName: true,
fullName: true,
description: true,
},
},
workTopics: {
select: {
topic: {
select: {
id: true,
name: true,
},
},
},
},
workLikes: {
select: {
id: true,
},
},
},
},
},
},
},
where: {
followerId,
},
});