The delete methods on aDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/fajarnugraha37/drizzle-castor/llms.txt
Use this file to discover all available pages before exploring further.
Repository instance cover three distinct lifecycles: soft deletion (marking records as deleted while keeping them in the database), restoration (reversing a soft delete), and hard deletion (permanently removing rows). Soft-delete and restore operations require the softDelete configuration block to be present on the table in the schema builder. Hard-delete methods work on any table regardless of soft-delete configuration. All methods emit lifecycle events that you can subscribe to for audit trails and telemetry.
softDeleteOne
Marks a single active record as deleted by applying thedeleteValue configured in the softDelete block. The record remains in the database and can be queried via searchDeletedOne or restored via restoreOne.
Signature
"soft-deleted" event on success, carrying tableName, action, records, and traceId.
Parameters
The primary key value of the record to soft-delete. The method only targets currently active (non-deleted) records; it will not re-delete an already soft-deleted record.
The RBAC profile (or profiles) to evaluate. The
"softDelete" action must be listed in allowedActions for the profile, otherwise an AccessDeniedError is thrown. Defaults to "default" when omitted.Return value
true if a matching active record was found and soft-deleted. false if no active record with the given id exists.Example
softDeleteMany
Applies a soft-delete to all active records matching a filter condition. Returns the count of records that were soft-deleted. Signature"soft-deleted" event (with the full list of affected records) when at least one record is deleted.
Parameters
A structured filter object using operator keys (
$eq, $like, $or, $and, etc.) and dot-notation paths. Only currently active records are considered; soft-deleted records are excluded from the match automatically.RBAC profile(s) to evaluate. The
"softDelete" action must be permitted for the active profile.Return value
The count of records that were soft-deleted. Returns
0 when no active records matched the filter.Example
restoreOne
Reverses a soft delete on a single record by applying therestoreValue configured in the softDelete block. The record must currently be in the soft-deleted state; active records are not affected.
Signature
"restored" event on success, carrying tableName, action, records, and traceId.
Parameters
The primary key value of the soft-deleted record to restore. The method only targets records in the deleted state.
RBAC profile(s) to evaluate. The
"restore" action must be listed in allowedActions for the active profile.Return value
true if a matching soft-deleted record was found and restored. false if no soft-deleted record with the given id exists.Example
restoreMany
Restores all soft-deleted records matching a filter condition. Returns the count of records that were restored. Signature"restored" event (with the full list of restored records) when at least one record is restored.
Parameters
A structured filter object. Only soft-deleted records are considered as candidates for restoration; active records are excluded automatically.
RBAC profile(s) to evaluate. The
"restore" action must be permitted.Return value
The count of records that were restored to active status. Returns
0 if no soft-deleted records matched.Example
hardDeleteOne
Permanently removes a single record from the database. This operation is irreversible. Unlike soft-delete methods, this works on any table regardless of soft-delete configuration, and targets the record in its current state — active or deleted. Signature"hard-deleted" event on success, carrying tableName, action, records, and traceId.
Parameters
The primary key value of the record to permanently delete.
RBAC profile(s) to evaluate. The
"hardDelete" action must be listed in allowedActions for the active profile.Return value
true if a record with the given id was found and permanently deleted. false if no matching record existed.Example
hardDeleteMany
Permanently removes all records matching a filter condition. Returns the count of deleted records. Signature"hard-deleted" event (with the full list of deleted records) when at least one record is removed.
Parameters
A structured filter object using operator keys and dot-notation paths. All records matching the filter — regardless of soft-delete state — are permanently removed.
RBAC profile(s) to evaluate. The
"hardDelete" action must be permitted.Return value
The count of records permanently deleted. Returns
0 if no records matched the filter.Example
Configuring soft delete
For soft-delete and restore methods to function, the table must be configured with asoftDelete block in the schema builder:
deleteValue and restoreValue objects map directly to column names on the physical table. Any column included in your Drizzle schema can be used — numeric flags, boolean columns, and nullable timestamp columns are all common choices.