Sign Up
Loading...

Database

Watch the walkthrough

Database Commands

Read and change database records from workflow commands.

Recorded with an earlier Twidget interface. Names, control locations and available options may differ; use the linked documentation for current guidance.

Watch tutorial (4:56)

Browse all video tutorials

Twidget offers many commands to manage data in your database. Below is a list of the available commands and their functionalities:

Get Data

Retrieve an entry from a table.

Get Multiple Data

Retrieve multiple entries from a table.

Save Data

Save an object to a database table.

Save Multiple Data

Save multiple objects to a database table.

Update Data

Update an entry in a table.

Update Multiple Data

Update multiple entries in a table.

Delete Data

Delete an entry from a table.

Delete Multiple Data

Delete multiple entries from a table.

Count Records

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.

Has Record

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.

Add or Update Record

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.

Increment or Decrement Field

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.

Summarize Records

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.

Database Transaction

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.

External Database Query

Read records from a saved external database connection. Select the connection, provide a query, and bind changing values through Parameters. See External database connections.

Run events after record changes

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.

Step-by-step guides

For examples and setup details, see Summarise Records, Save Changes Together, and External Database Connections.

Related Topics

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

Date

Twidget offers a variety of commands to manipulate date objects. Below are the available commands along with their respective descriptions, inputs, and outputs. Current Date. Description: Returns the current date and time. Output: - Type: DATE Add Time. Description: Returns the date plus a specified...

Process PDF files

Inspect a PDF, combine documents, copy selected pages into a separate file, or read existing text. Find PDF information, Merge PDFs, Select PDF pages and Extract PDF text under File Manager when adding a command to a server workflow. Use a file containing its contents. Choose an uploaded file, an ea...

Connector Commands

Connector Commands allow you to integrate Twidget projects with external services such as Google Drive, Slack, OpenAI’s ChatGPT, and many others. These commands provide ready-made actions that communicate with third-party APIs, removing the need to manually create and maintain external HTTP requests...

Managing Files

Twidget offers a set of commands to manipulate files in your file store. Below are the descriptions and usage of each command to help you understand how to utilize them effectively. For CSV, ZIP archives and temporary download links, see [Advanced file commands](/docs/commands/advanced-files). Get F...