Parameters
The updateRecords() method object can contain the following properties:
| Parameter | Type | Required | Description |
|---|---|---|---|
table | string | Yes | The name of the table to update. |
data | Record<string, any> | UpdateRecordRow[] | Yes | The data payload for the update. This can be a single object (for conditional updates) or an array of objects (for batch updates). See Data payload structure. |
where | Record<string, any> | Yes | A filter object with conditional logic used to identify the records that should be updated. This parameter is always required. |
options | UpdateRecordsOptions | No | Configuration flags that control the behaviour of the update. See Update records options. |
with | Record<string, UpdateNestedRecord> | No | An object specifying related tables to update simultaneously. See Nested updates. |
Data payload structure
The data parameter supports two structures:
-
Single Object Payload: Used when performing a single update on a filtered set of records.
TypeScriptdata: { name: 'New Name', status: 'active' } -
Array Payload (
UpdateRecordRow[]): Used for batch updates, where each object can optionally contain per-row validation rules.Field (in Array Object) Type Required Description [Fields to Update]Record<string, any>Yes The object containing the fields and their new values for the update. validationRecord<string, ValidationRule>No Per-row validation rules to be applied before the update.
Update records options
| Option | Type | Default | Description |
|---|---|---|---|
sanitize | boolean | true | Cleans input values (for example stripping dangerous characters) before saving them to the database. |
upsert | boolean | false | If true, a new record is inserted if no existing record matches the where criteria. |
conflictKeys | string[] | [] | An array of fields used to detect conflicts during an upsert operation. |
conflictKeysLogic | 'and' | 'or' | 'and' | Specifies how to combine the conflict keys using logical and or or. |
transactional | boolean | false | If true, the update is treated as a single transaction. All updates must succeed or all fail. |
chunkSize | number | 1000 | The batch size for processing large arrays of records. |
dryRun | boolean | false | Simulates the update and returns the intended changes without modifying the database. |
continueOnError | boolean | false | If true, processing continues even if some records fail to update. |
validationRule | Record<string, ValidationRule> | {} | A global validation object applied to all records in the update. |