Databases - Advanced
Custom Database Functions

Custom Database Functions

You may want to create your own functions, in addition to what is auto-generated when you connect a data source. Custom functions (for a database) 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 → Data Sources. Click on the desired data source. 

Under “Functions", click on “Add New”. You can also go to the Function Library and click “+Function” with a data source selected. 

Name your function, then select the data source the function interacts with.

Action Type

There are three types of actions that your custom function can perform:

  • Insert: This will create a new data record and allow you to set values for data fields
  • Update: This will update particular record(s) using filter criteria and allowing you to set values for data fields
  • Delete: This will delete particular record(s) using filter criteria

Then 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. 

First, select the fields that you want to filter on, then choose how you want to compare ("greater than", "is equal to", "contains", etc). Finally enter in the comparison value.

If the value you want to compare against is not a fixed value, you can use Javascript template literals. Any Javascript expressions will become a dynamic parameter, which you'll see listed at the bottom. Later on, when you configure a component to use this function, you'll define where the values for your parameters come from.

Note: there are some edge cases in how we convert to template literal, please see the dynamic parameters documentation for details.

Click "X" to remove a filter and "+Add filter" to add more filters. Each filter is an “AND” statement - records must pass all filter criteria in order to be acted upon. 


(only appears for Insert and Update actions)

This allows you to set new values for the fields you specify.

First, select the field that you want to set a new value for. Then enter in a value that you want to set this field to. Usually this will not be a fixed value, so you should use Javascript template literals to create a dynamic parameter (your Javascript expressions become dynamic parameters, listed at the bottom).

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 create your function.

Note: You’ll configure how values for your dynamic parameters are populated when you use this function in a component.