You may want to create your own functions, in addition to what is auto-generated when you connect a data source. One use of custom functions is to allow you to bulk update multiple records, based on filter criteria you define. Currently you can create custom functions for PostgreSQL, MySQL, and Cassandra data sources.
To create a custom function for a database, first navigate to Company Settings (left navigation) → Data Sources (tab). Click on the desired data source.
In the “Functions” section, click on “Add New”. Note you can also go to the Function Library and click “+Function” with a data source selected.
Enter in a name for your function at the top.
Data Source: Select the data source you want this function to act on (this is pre-selected if you create a function from a data source page).
Action Type: There are three types of actions that your custom function can perform:
Resource: Select the resource you want this function to act on.
Filter by: (only appears for Update and Delete actions)
You’ll use filters to identify the particular records you want the function to act on.
You can click on the “X” to the right of a filter to remove a filter.
Click “+Add filter” to add another filter. Each filter is an “AND” statement - records must pass all filter criteria in order to be acted upon.
Set: (only appears for Insert and Update actions)
This allows you to set new values for the fields you specify.
Allow multiple records to be updated: This checkbox provides an additional safety net in case you do not intend for this function to perform bulk update actions. If this is unchecked, the function will fail if it attempts to act on more than one record.
Hit “Apply” to finish creating your function. It’s now ready for you to use in a Space component.
Note: You’ll configure how values for your dynamic parameters are populated when you use this function in a component.