-
-
Notifications
You must be signed in to change notification settings - Fork 126
Open
Description
Background
Current pattern: https://zenstack.dev/blog/soft-delete
But it has some limitations:
- You can't call the regular
deletemethod onDeletereferential 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:
deleteanddeleteMany(including nested ones) become soft deleteonDelete: Cascadepropagate 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