Michael Rea
Michael Rea14mo ago

Use helper functions or internalAction?

I'm saving an image from an internal action. Am I meant to call another internal action or can I just use a regular function? What is the benefit of using an internalAction over a regular function?
No description
3 Replies
Michael Rea
Michael ReaOP14mo ago
Still wrapping my head around the convex best practices. I'm guessing I should be avoiding Actions unless I NEED to use them is that right?
lee
lee14mo ago
I would recommend calling a function directly when you can. This reduces overhead, since a new action would get a new javascript environment and serialize the args & return values. ctx.runAction is most helpful for switching between the convex runtime and node.js. And you're right, actions should only be used when necessary. If you can do it in a mutation, that has even less overhead and better guarantees.
Michael Rea
Michael ReaOP14mo ago
Thanks, okay so should aim for mutations if possible otherwise a function and an action only when necessary.

Did you find this page helpful?