ThePndaXpres
ThePndaXpres5mo ago

ctx.db undefined

I am trying to use .get to get an entry by its id but I am getting the error Server Error Uncaught TypeError: Cannot read properties of undefined (reading 'get') Here is my code snippet: export const chat = action({ args: { imageId: v.string(), }, handler: async (ctx, args) => { console.log(args.imageId); const document = await ctx.db.get(args.imageId); return await ctx.storage.getUrl(document.body); }, });
3 Replies
RJ
RJ5mo ago
Hi @ThePndaXpres—actions can't interact with the database directly, but they can call other queries and mutations which do. See https://docs.convex.dev/functions/actions
Actions | Convex Developer Hub
Actions can call third party services to do things such as processing a payment
ThePndaXpres
ThePndaXpresOP5mo ago
thank you!
RJ
RJ5mo ago
In this particular example above, you may just wish to use a query instead

Did you find this page helpful?