Twidget offers many commands to manage data in your database. Below is a list of the available commands and their functionalities:
-
Retrieve an entry from a table.
Retrieve multiple entries from a table.
Save an object to a database table.
Save multiple objects to a database table.
Update an entry in a table.
Update multiple entries in a table.
Delete an entry from a table.
Delete multiple entries from a table.
Count records matching your filters without returning the records themselves. Choose a table, add any filters and set a Return as name such as open_orders. The result is a number, including 0 when nothing matches.
In this example, the test uses a sample table containing four matching orders and returns 4.

Check whether at least one record matches. For example, look for a registration with the same event and email before deciding what to do next. The result is true or false.
This test found a matching sample order, so its result is true.

This is useful for decisions, but does not prevent two simultaneous requests creating duplicates. Use a unique index when duplicates must be prevented.
Find a matching record and update it, or add a new record if none exists. Choose a table, define filters that identify the record, and supply the values to save.
For example, match a product by its unique product code and save its latest description and price. Use a unique index on the matching field when it identifies a single record.
This sample matches an order by reference. Supply the values to save below the query.

The test returns the saved order, including its reference and amount.

Change a number field by an amount. An amount of 1 increases it by one; -1 decreases it by one. Choose the matching record, the number field and the amount.
This command is useful for counters and stock changes because it applies the change directly, rather than separately reading a number and saving a replacement. Decide how your workflow should handle missing records and values below zero.
Here, the command finds ORDER-1001, increases its amount by 2, and returns the record After change. Use a negative Change by value to decrease the amount.

Summarise matching records with a count, total, average, lowest or highest value. Optionally choose Group by to produce a summary for each category, customer or other field. See Summarise records.
Use Database Transaction to group supported database commands so their changes succeed together. If the block fails, its changes are rolled back. See Save changes together for limitations and examples.
Read records from a saved external database connection. Select the connection, provide a query, and bind changing values through Parameters. See External database connections.
Use Settings → Database Triggers to run a published event after a live workflow command creates, updates or deletes a record. See Database change triggers for setup, input values and limits.
For examples and setup details, see Summarise Records, Save Changes Together, and External Database Connections.
Text
Twidget offers a variety of commands to manipulate text in various ways. To Uppercase. Converts all characters of the provided text to uppercase. - text: The text to be converted to uppercase. - A text string with all characters in uppercase. To Lowercase. Converts all characters of the provided tex...
Page Security
Use these commands in page workflows to check reCAPTCHA before accepting a form submission. Configure your keys first; see [Page Settings](/docs/pages/page-settings) and the existing [reCAPTCHA guide](/docs/pages/recaptcha). Generate reCAPTCHA token. Generates a token for the current interaction. Th...
Send Message
Send SMS Command. With Twidget, you can send SMS messages to phones using the `Send SMS` command. This functionality varies depending on the provider. Currently, we support Twilio as the SMS provider. To use Twilio for SMS integrations, you will need: - A Twilio account ID - Twilio Auth Token - A Tw...
Error Handling
When building applications with Twidget, you may encounter situations where you need to handle errors gracefully to ensure your application runs smoothly. Twidget provides two powerful commands for error handling: `try-catch` and `throw-error`. This documentation will guide you on how to use these c...
Send External HTTP Request
Using Twidget, you can send external HTTP requests effortlessly. This functionality allows you to communicate with external servers or APIs. Below, you will find the necessary parameters and structure to set up an HTTP request. Parameters. - URL: The endpoint to which the request will be sent. - Met...