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.
- Manta Studio
- PostgreSQL
TypeScript
try {
const result = await manta.deleteRecords({
table: "critical_data",
where: { id: 1 },
options: { transactional: true },
});
} catch (error) {
// Gracefully handle internal table errors
console.error("Manta deletion failed:", error.message);
}
TypeScript
try {
const result = await manta.deleteRecords({
db: "production_db",
table: "critical_data",
where: { id: 1 },
options: { transactional: true },
});
} catch (error) {
// Gracefully handle PostgreSQL-specific errors (e.g., connection or constraints)
console.error("Postgres deletion failed:", error.message);
}