type DatabaseQuery = {
where?: FilterGroup
sort?: SortClause[]
limit?: number
offset?: number
}
type FilterGroup = {
logic: string // "and" or "or"
conditions: FilterCondition[]
}
type FilterCondition = {
type: string // "comparison" or "group"
columnId?: string // comparison only
operator?: string // comparison only: eq, neq, gt, gte, lt, lte, contains, not_contains, starts_with, ends_with, is_empty, is_not_empty
value?: string // comparison only
group?: FilterGroup // group only
}
type SortClause = {
columnId: string
direction: string // "asc", "desc" or "random"
}
Update Matching Rows
BlockDatabases
Find rows matching a query and update them all with the specified values.
- Gets an extra input or output for each column of the database you pick.
Inputs
DatabaseRequired
Select the database to update.
Limit
Maximum number of rows to update (default: 100, max: 1000).
Example: 100
Update Mode
How to handle empty fields: keep existing values or replace with empty.
OptionsKeep existing valuesReplace all values
Query
Define filters to find the rows to update.
Set up in the editor. The JSON format is under advanced documentation below.
Outputs
Updated Count
The number of rows that were updated.
Example: 5
Build a bot using blocks like Update Matching Rows
Use this block in our visual flow editor. Bots are hosted 24/7 for free on inventor.bot.
Advanced Documentation
This documentation can be useful when using code mode. View as Markdown
ID:
db_update_matching_rows- Database columns are extra inputs/outputs named
dbcol_<column name>.
Inputs
| Field | InventScript name | Value |
|---|---|---|
| Database | database_id | |
| Limit | limit | e.g. "100" |
| Update Mode | update_mode | "Keep existing values", "Replace all values" |
| Query | query_json | JSON text |
query_json format: JSON text of type DatabaseQuery. Fields marked ? are optional.Outputs
| Field | InventScript name | Value |
|---|---|---|
| Updated Count | updated_count | e.g. "5" |
Example InventScript
matchingRows := db_update_matching_rows(Args{database_id: "..."})
send_text_message(Args{
channel_id: trigger.channel_id,
message_content: "Updated Count: " + matchingRows.updated_count,
})
More databases blocks
Database Lookup (Single)Find a single row from a database matching your query. Returns the first matching row.Database Lookup (Iterator)Find multiple rows from a database and iterate over each one.Database Create RowCreate a new row in a database with the specified values.Database Duplicate RowDuplicate an existing row in a database by its ID.Database Update RowUpdate an existing row in a database with new values.Clear Row DataClear selected columns from a database row. Does nothing if the row does not exist.Clear Matching Row DataFind rows matching a query and clear selected columns from all of them.Delete Matching RowsDelete rows matching a query and return how many were deleted.Database Delete RowDelete a row from a database by its ID.