Closed Avishayy closed 1 year ago
Thank you for using it and I'm glad it's useful for you!
On the matter of additional fields - That's a custom pattern of your system - for softdeletion to work, only the deleted_at
field is needed to be looped into the library stuff. and keeping it as simple as possible is a Good Goal To Have (TM) 😄
For customizing the mixin, you don't need to edit anything in the library, only subclass the mixin you created with the library with your own extra behavior. Here's how you can achieve that:
class SoftDeleteMixin(
generate_soft_delete_mixin_class(...)
):
deleted_at: datetime
class SoftDeleteDetailedMixin(SoftDeleteMixin):
deleted_reason: Optional[str]
deleted_by: Optional[str]
# override delete with your custom logic/additional fields
def delete(...)
then, just use your SoftDeleteDetailedMixin
in all your tables. easy peasy 😉
Please let me know if this wasn't clear enough or if there's anything else I can be of help!
--Cadu
Ah, I didn't realize I could overwrite the delete method this way, thank you!
Having additional fields for soft deleted objects can be helpful to add visibility, for example (very rough prototype):
Then one would be able to do:
I might have some time later this month to create a PR by myself, but I still wanted to write it out.
I like the project, thank you for developing it!