Syntax
First, import the MantaClient from the library, see Getting Started:
Parameters
The deleteRecords() method object can contain the following properties:
Conditional delete
Use the where parameter with friendly syntax operators to target specific records for deletion. These operators work identically across both internal Manta Tables and external PostgreSQL databases.
Soft delete
Set options.softDelete to true to mark records as deleted rather than permanently removing them from the database. This process allows for data recovery and maintains audit trails.
Multi-table delete
Use the with parameter to delete records in one or more related tables as part of the primary deletion operation. This is useful for maintaining referential integrity by cleaning up associated data.
Transactional delete
Set options.transactional: true to treat all primary and nested deletions as a single operation. If any part of the operation fails, the entire transaction rolls back, ensuring no data is partially deleted.
Error handling
Wrap your deleteRecords() call in a try/catch block to gracefully handle failures. This is especially important when using options.transactional: true, as any failure will trigger a rollback.
Examples
This section provides common, practical examples demonstrating various ways to use the deleteRecords() method.