hocinoH
Convex Community14mo ago
12 replies
hocino

custom functions and getAll helper

Hi everyone🙂 ,

I create two custom functions to handle my queries and mutations.
Now, when I use the getAll helper as below I have some strange errors. Except that I can query or mutate everything with my customFunctions.
Do you have any idea what is the problem ? Did I do something wrong with my custom Functions ?
Thanks 🙏
GetAll :
applicationsToUpdate = await getAll( ctx.db, childrenApplicationsIds.map((x) => x as Id<'applications'>) );

Here, thrown errors :
Uncaught TypeError: Cannot read properties of undefined (reading 'reader')
or
Uncaught TypeError: Cannot read properties of undefined (reading 'db')

My customs functions:
export const SecureMutationBuilder = customMutation(mutation, { args: {}, input: async (ctx, args) => { const { userId, userPermissions } = await getPermissions(ctx); const db = wrapDatabaseWriter( { userId }, ctx.db, await rlsRules(ctx, userId, userPermissions) ); return { ctx: { db, userId, userPermissions }, args }; } }); export const SecureInternalMutationBuilder = customMutation(internalMutation, { args: {}, input: async (ctx, args) => { const { userId, userPermissions } = await getPermissions(ctx); const db = wrapDatabaseWriter( { userId }, ctx.db, await rlsRules(ctx, userId, userPermissions) ); return { ctx: { db, userId, userPermissions }, args }; } });
Was this page helpful?