Cloud Code for Data is similar to a trigger in a conventional database. This type of code gets executed whenever an item is created, read, updated, or deleted. Furthermore, you can plug your code both before the query is executed and after the result is obtained. This way you can both change the query or change the result based on your custom logic.
There are many scenarios where Content Type Code can be useful. Some examples are:
- Validating data before inserting or updating items
- Updating related data on inserting or updating items
- Sending emails or push notifications after inserting or deleting items
- Enhancing data before returning it to the client (adding custom fields to items, fetching related data, etc.)
You can read more in Cloud Code for Data.
With cloud functions you can create your own code working in the cloud and call it whenever you need. Cloud functions can accept parameters and can return a result.
Each cloud function is assigned a unique RESTful endpoint. To invoke the cloud function you need to make an HTTP request to the endpoint's URL. Parameters to the function are supplied as query parameters in the URL or as HTTP headers. You can also use the body of the request to send any data you want. The result of the function is obtained through the HTTP response.
Cloud Functions can be useful in various scenarios. Some examples are:
- Server-side logic that is not triggered by a data operation
- Hook for integration with external products and services
- Generating reports
You can read more in Cloud Functions.