PatolordP
Convex Communityโ€ข5mo agoโ€ข
5 replies
Patolord

Query mutation with high writes?

Am i doing something wrong, this is just a query but show in red( writes) usage?

// 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;
  },
image.png
Was this page helpful?