Syntax
The updateRecords method modifies existing records in a table based on specified filters. It supports both native Manta tables and external PostgreSQL databases.
Parameters
The updateRecords() method object can contain the following properties:
Conditional updates
Use the where parameter with friendly syntax operators to target specific records for an update.
Validation
MantaHQ supports both global and per-row validation rules to ensure data integrity during updates. These rules prevent malformed data from reaching your internal Manta tables or external PostgreSQL databases.
Nested updates
Use the with parameter to update records in one or more related tables as part of the primary update operation. This ensures data consistency across related entities in both Manta data tables and external PostgreSQL databases.
Upsert operations
Set options.upsert to true to perform an "upsert" (update or insert). If the SDK finds a record matching your where clause, it updates that record. If no match is found, it inserts a new record.
Transactional updates
Set options.transactional to true to treat all updates (primary and nested operations) as a single transaction. If any part of the operation fails (e.g., a validation error or a database constraint violation), the SDK rolls back all changes to ensure your data remains in its original state.
Dry Run
Set options.dryRun to true to simulate the update process. The API returns a detailed report of the changes that would have been applied without modifying any data in your database. This is useful for testing complex filters or validation rules before executing them.
Error handling
Wrap your updateRecords() call in a try/catch block to gracefully handle validation errors or transaction failures.
Examples
The following examples demonstrate common use cases for the updateRecords() method across internal Manta tables and external PostgreSQL databases.