Use cases for internal functions
Leverage internal functions by:- Calling them from actions via
runQueryandrunMutation - Calling them from HTTP actions via
runQuery,runMutation, andrunAction - Scheduling them from other functions to run in the future
- Scheduling them to run periodically from cron jobs
- Running them using the Console
- Running them from the CLI
Defining internal functions
An internal function is defined usinginternalQuery, internalMutation, or
internalAction. For example:
internalQuery
or internalMutation it’s a better idea to pass around document IDs instead of
documents, to ensure the query or mutation is working with the up-to-date state
of the database.
Internal function without argument validation
Internal function without argument validation
Calling internal functions
Internal functions can be called from actions and scheduled from actions and mutation using theinternal object.
For example, consider this public upgrade action that calls the internal
plans.markPlanAsProfessional mutation we defined above:
internal.plans.markPlanAsProfessional without going through the upgrade
action — if they did, then they would get a free upgrade.
You can define public and internal functions in the same file.