Best practice to store "callbacks" in database?
For example, let's say I have a JS interface for game achievement:
What is the best practice to represent this in Convex DB? Or in any DB?
My thought is to store reference to a query function (in my code) in
isCriteriaMet
field; store reference to a mutation function in reward
field. Or maybe just references to helper functions with context?
If implemented this way, is there a Convex internal API where I can sync the list of query/mutation functions I defined in my code to the Convex DB, so I can safely reference them in another table?2 Replies
Thanks for posting in <#1088161997662724167>.
Reminder: If you have a Convex Pro account, use the Convex Dashboard to file support tickets.
- Provide context: What are you trying to achieve, what is the end-user interaction, what are you seeing? (full error message, command output, etc.)
- Use search.convex.dev to search Docs, Stack, and Discord all at once.
- Additionally, you can post your questions in the Convex Community's <#1228095053885476985> channel to receive a response from AI.
- Avoid tagging staff unless specifically instructed.
Thank you!
Welcome! Apart from the specific approach you’ve outlined, this is a pretty simple use case - you would determine if criteria is met at runtime in your Convex function.
Here's a contrived mutation that depicts what I think you're going for: