delete
Permanently remove a database record by its ID, including related graph edges and triggering deletion events. This irreversible operation fails if foreign key constraints exist.
Instructions
Delete a specific record from the database by its ID.
This tool permanently removes a record from the database. Use with caution as this operation cannot be undone. The deletion will also:
Remove any graph edges (relations) connected to this record
Trigger any defined deletion events/hooks
Fail if the record is referenced by FOREIGN KEY constraints
Args: thing: The full record ID to delete in format "table:id" (e.g., "user:john", "product:laptop-123") namespace: Optional SurrealDB namespace override. If not provided, uses SURREAL_NAMESPACE env var. database: Optional SurrealDB database override. If not provided, uses SURREAL_DATABASE env var.
Returns: A dictionary containing: - success: Boolean indicating if deletion was successful - deleted: The ID of the deleted record - data: The deleted record data (if available) - error: Error message if deletion failed (only present on failure)
Examples: >>> await delete("user:john") {"success": true, "deleted": "user:john", "data": {"id": "user:john", "name": "John Doe"}}
>>> await delete("product:nonexistent")
{"success": true, "deleted": "product:nonexistent", "data": null} # No error even if record didn't existNote: This operation is irreversible. Consider using soft deletes (status fields) for recoverable deletions.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| thing | Yes | ||
| namespace | No | ||
| database | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||