Pedram
Pedram
CCConvex Community
Created by Pedram on 11/22/2024 in #support-community
Type error on internal query
The following doesn't work because secrets.get expects a QueryCtx.
// openAi.ts
export const setTokenIfNotPresent = internalAction({
handler: async (ctx, _) => {
const secret = await secrets.get(ctx, {key: 'openAiKey'})
if (secret === null) // obtain and set new token
})

// secrets.ts
export async function get(ctx: QueryCtx, key: string) {
ctx.db.query('secrets').filter(q => q.eq('key', args.key)).unique()
})
// openAi.ts
export const setTokenIfNotPresent = internalAction({
handler: async (ctx, _) => {
const secret = await secrets.get(ctx, {key: 'openAiKey'})
if (secret === null) // obtain and set new token
})

// secrets.ts
export async function get(ctx: QueryCtx, key: string) {
ctx.db.query('secrets').filter(q => q.eq('key', args.key)).unique()
})
9 replies
CCConvex Community
Created by Pedram on 11/22/2024 in #support-community
Type error on internal query
I have a follow-up question. What is the best way to call a helper function that needs a QueryCtx from an internalAction?
9 replies
CCConvex Community
Created by Pedram on 11/22/2024 in #support-community
Type error on internal query
Thank you! Helper functions are what I need to use.
9 replies