I want to paginate the results of my query, I was unable to find any examples in the docs so can someone please help me with it?
The query I want to paginate -
export const getChunks = internalQuery({
args: { chatId: v.id("chatbook") },
handler: async (ctx, args) => {
const chunks = await ctx.db
.query("chatbookChunks")
.withIndex("by_chatId", (q) => q.eq("chatId", args.chatId))
.take(50);
return chunks;
},
});
I want to get all the results of a specific chatId till we have reached the end, how can I get the results in here?
const chunks = await ctx.runQuery(internal.helper.chunks.getChunks, {
chatId: args.chatId,
});