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();
},
});
7 Replies
hi @rutenisraila, thanks for reporting! we've identified the issue and will have it fixed shortly.
we'll update the thread here once it's resolved.
thanks for a quick response! @sujayakar
@rutenisraila Can you confirm if you can still observe the issue?
now it seems like I can't get any options at all. They do appear in the Convex dashboard, but the types and data seems to be not syncing to my code.
I restarted convex dev server. Could be that I missed something so attaching some screenshots
I see the schema is not visible so attaching the full screenshot for reference
Are you missing a return statement?
in getByDecisionId
💀 you're right, seems like it works with indexes now!