-
-
Notifications
You must be signed in to change notification settings - Fork 116
Open
Description
Background
Current pattern: https://zenstack.dev/blog/soft-delete
But it has some limitations:
- You can't call the regular
delete
method onDelete
referential actions don't work
Proposed Solution
The thought is to make it as simple as:
model Foo {
...
deletedAt DateTime? @softDelete
}
And the enhance()
API can have an option to opt-in for it:
const db = enhance(prisma, { user: ..., softDelete: true });
When enabled, the enhanced client has additional behavior:
delete
anddeleteMany
(including nested ones) become soft deleteonDelete: Cascade
propagate soft-delete to related entities- Read APIs (findXXX, count, aggregate, groupBy) automatically exclude soft-deleted entities
More Context
Context from chat with ikishan on discord:

clementoriol, dugramen, DawidWraga, sourcebert, dikyarga and 9 more