You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, the prisma-extension-soft-delete library provides support for soft deleting records by adding a deletedAt or deleted field to models. However, in many applications, it is also necessary to track who deleted the record by adding an additional field such as deletedBy.
This feature would allow developers to store the ID of the user (or another identifier) responsible for soft deleting the record. This is particularly useful for auditing and security purposes.
Proposed Solution
Enhance the createSoftDeleteExtension function to support an optional deletedBy field (or any additional custom field) that stores the identifier of the user who performed the deletion.
Example Configuration
The extension should allow users to specify an additional field for tracking deletions, like this:
additionalFields: A new property that allows defining extra fields for soft delete, such as deletedBy.
deletedBy: (deleted, context) => ...
If deleted is true, it sets the deletedBy field to context.userId.
Otherwise, it resets the deletedBy field to null.
context: Represents additional metadata (e.g., the currently authenticated user).
Expected Behavior
When a record is soft deleted, the deletedBy field should be automatically populated with the user ID.
If the record is restored (soft delete reversed), the deletedBy field should be set to null.
Developers should have the flexibility to configure multiple additional fields, not just deletedBy.
Use Case Example
If a user with id: 123 soft deletes a comment, the record should look like this:
{
"id": 1,
"content": "This is a comment",
"deletedAt": "2025-03-03T12:00:00.000Z",
"deletedBy": 123
}
Conclusion
This enhancement would significantly improve the usability of prisma-extension-soft-delete by providing a way to track the user responsible for deletions. It would be great to have support for this feature in the next release! 🚀
Would love to hear thoughts from the maintainers on feasibility and potential implementation! 😊
The text was updated successfully, but these errors were encountered:
Description
Currently, the
prisma-extension-soft-delete
library provides support for soft deleting records by adding adeletedAt
ordeleted
field to models. However, in many applications, it is also necessary to track who deleted the record by adding an additional field such asdeletedBy
.This feature would allow developers to store the ID of the user (or another identifier) responsible for soft deleting the record. This is particularly useful for auditing and security purposes.
Proposed Solution
Enhance the
createSoftDeleteExtension
function to support an optionaldeletedBy
field (or any additional custom field) that stores the identifier of the user who performed the deletion.Example Configuration
The extension should allow users to specify an additional field for tracking deletions, like this:
Explanation of the New Configuration
additionalFields
: A new property that allows defining extra fields for soft delete, such asdeletedBy
.deletedBy: (deleted, context) => ...
deleted
istrue
, it sets thedeletedBy
field tocontext.userId
.deletedBy
field tonull
.context
: Represents additional metadata (e.g., the currently authenticated user).Expected Behavior
deletedBy
field should be automatically populated with the user ID.deletedBy
field should be set tonull
.deletedBy
.Use Case Example
If a user with
id: 123
soft deletes a comment, the record should look like this:Conclusion
This enhancement would significantly improve the usability of
prisma-extension-soft-delete
by providing a way to track the user responsible for deletions. It would be great to have support for this feature in the next release! 🚀Would love to hear thoughts from the maintainers on feasibility and potential implementation! 😊
The text was updated successfully, but these errors were encountered: