// Get all completed sessions for the current user
export const getAllCompletedSessions = query({
args: {},
handler: async ctx => {
const userId = await getCurrentUserOrThrow(ctx);
// Get all completed sessions for this user, ordered by newest first
const sessions = await ctx.db
.query('quizSessions')
.withIndex('by_user_quiz', q => q.eq('userId', userId._id))
.filter(q => q.eq(q.field('isComplete'), true))
.order('desc')
.collect();
return sessions;
},// Get all completed sessions for the current user
export const getAllCompletedSessions = query({
args: {},
handler: async ctx => {
const userId = await getCurrentUserOrThrow(ctx);
// Get all completed sessions for this user, ordered by newest first
const sessions = await ctx.db
.query('quizSessions')
.withIndex('by_user_quiz', q => q.eq('userId', userId._id))
.filter(q => q.eq(q.field('isComplete'), true))
.order('desc')
.collect();
return sessions;
},
Join the Discord to ask follow-up questions and connect with the community
Join the Convex Discord! Explore Convex, the backend platform that keeps your app in sync.
16,164 Members
Join