rutenisrailaR
Convex Community3y ago
9 replies
rutenisraila

query invalidation not working with multiple indexes

Hi guys,

I've been experimenting with multiple indexes and I've noticed I'm able fetch the data by them just fine, but when I do a delete/add mutation the data stays the same. It does refresh after a full page reload.

I'm attaching a query example:

export const getByDecisionId = query({ args: { decisionId: v.id('decisions'), }, handler: async (ctx, args) => { if ( !args.decisionId) { return null; } const identity = await ctx.auth.getUserIdentity(); if (identity === null) { return null; } return await ctx.db .query('options') .withIndex('by_decision_id_and_user_token', (q) => q.eq('decisionId', args.decisionId).eq('userTokenIdentifier', identity.tokenIdentifier) ) .collect(); }, });

on the other hand, when combining multiple filters like in the example below, the UI updates after a delete/add mutation.

export const getByDecisionId = query({ args: { decisionId: v.id('decisions'), }, handler: async (ctx, args) => { if ( !args.decisionId) { return null; } const identity = await ctx.auth.getUserIdentity(); if (identity === null) { return null; } return await ctx.db.query('options') .filter((q) => q.eq(q.field('decisionId'), args.decisionId)) .filter((q) => q.eq(q.field('userTokenIdentifier'), identity.tokenIdentifier)) .collect(); }, });
Was this page helpful?