Open vitalinfo opened 2 years ago
Hi @vitalinfo I'm not sure what you have in mind. Can you give a code example of how this would be used?
In any case, you can prevent nested objects from being recovered by using parent.recover(recursive: false)
, and then recover selected nested objects manually.
@mvz yes, you are right for common case, but if you need some additional logic, like: you have a user, user has f.e. comments, both models are paranoid. User is able to remove comment and user could be removed as well. On user recover we need to recover all his comments, except comments which user removed by him self.
Assuming that you have some way to know which comments were deleted by the user, that would be something like:
user.recover(recursive: false)
user.comments.with_deleted.not_removed_by_user.recover
@mvz yes, this will work, but if user model has a lot of associations, the recover complexity will be huge
@vitalinfo and how will this feature help with that? What would the code look like?
I'll do this feature, in worse case I'll use fork in my project
@mvz What do you think about skip recover functionality? This feature could be helpful for nested objects, where you will be able to mark object as skippable for recover (in the
before_recover
hook) If you approve it, I can prepare the PR with implementation