Creating an API Action
Right click API and select Add API Action:
Give it a name, we call our API Action - records
:
You can see the API Action, loaded in a separate tab. There you will find its steps and that’s where we define all the server side logic that we need.
Creating a Database Query
Right click steps:
Open Database Actions and select Database Query:
Basic Options
Your existing database connection will be automatically selected in the dropdown. If you have more than one database connections defined, make sure select the one you need:
Click the Query Builder button:
Selecting Tables and Columns
Open the database tables drop-down and select a table:
If you want to add all the table columns to the query, you don’t have to do anything else - the table is already added. If you want to add specific columns to the query, just select them (using Ctrl + click / Cmd + click) and click the add button:
Query Conditions
You can add conditions/filters to your database query. Click the Conditions tab:
Here you can setup your query conditions, just select a column:
Then select a condition:
And add a value for the condition. This can be a dynamic value, or a static one. In our example we add a static value:
You can add multiple conditions or groups of conditions to your queries. Click the Add New Condition buton:
Just select how to combine these conditions - using the AND or OR operators. Clicking the operator toggles it from AND to OR.
Selecting AND will only return records which match both conditions, while using OR will return any records matching any of the conditions.
We set the operator to AND:
And then we setup our second condition:
Sorting Query Results
You can add sorting options to your query, select the Sorting tab:
Select the column you want to sort the query by and add it to the sort list:
Then just select the sort order:
You can see the generated code for the database query, which you just set up:
Click OK in order to apply the query options:
Previewing the Results
Make sure the Output option is enabled. When disabled, the query results won’t be displayed on the freont-end:
Do not forget to save your server action by using the Ctrl + S
/ Cmd + S
shortcut:
You can preview your query results by selecting the server action and then clicking the Open in Browser button:
The results will be loaded in your browser:
Last updated: