rutenisraila
CCConvex Community
•Created by rutenisraila on 9/11/2023 in #support-community
Can't get users in Convex functions
18 replies
CCConvex Community
•Created by rutenisraila on 8/29/2023 in #support-community
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();
},
});
10 replies
CCConvex Community
•Created by rutenisraila on 8/22/2023 in #support-community
missing delete mutation example in the docs
17 replies