> For the complete documentation index, see [llms.txt](https://docs.xenioo.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.xenioo.com/actions-and-operations/database/database-function.md).

# Database Function

This action will execute a standard query function on an [active cursor.](/actions-and-operations/database/query-collection-data.md)

<figure><img src="/files/bIzal4f9gPdlOTZplpzU" alt=""><figcaption></figcaption></figure>

### Settings

The action uses the following settings:

| Setting  | Description                                                                  | [Parsed](/actions-and-operations/dynamic-parsing.md) |
| -------- | ---------------------------------------------------------------------------- | ---------------------------------------------------- |
| Function | The function to be executed                                                  | :no\_entry:                                          |
| Field    | The name of the field to be used as parameter for the function, if required. | :white\_check\_mark:                                 |

### Remarks

This action will execute one of three different functions using an active query cursor. After the function is executed, the cursor is closed.

<table><thead><tr><th width="163">Function</th><th>Result</th></tr></thead><tbody><tr><td>Count</td><td>Will return the amount of elements returned by the query</td></tr><tr><td>Sum</td><td>Will sum all values in the specified field. Any field value that cannot be translated to a number will be threated as a zero.</td></tr><tr><td>Unique Values</td><td>Will return a model containing an array with all the unique values of the specified field.</td></tr></tbody></table>

{% hint style="warning" %}
Function execution does not rewind the current cursor. Using this action on a cursor that already moved may lead to incorrect values.
{% endhint %}

### Trigger

This action does not have any trigger.

### Variables

This action produces the following variables after being triggered:

| Variable                   | Description                          |
| -------------------------- | ------------------------------------ |
| database\_function\_result | The result of the function execution |

### Availability

### Availability

Channel specific availability follows the table below:

| Channel          | Availability     |
| ---------------- | ---------------- |
| Facebook         | Fully Available. |
| WhatsApp         | Fully Available. |
| SMS              | Fully Available. |
| Telegram         | Fully Available. |
| Web              | Fully Available. |
| Alexa            | Fully Available. |
| Google Assistant | Fully Available. |
| Slack            | Fully Available. |
| API              | Fully Available. |

This action requires an active [Database ](broken://pages/-LdYpe93z-UqrvvQdX7V)package. This action can only be used as an operation for a [Save ](/database/database-api-access/save-to-collection.md)action.
