Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question: Skip recover functionality #267

Open
vitalinfo opened this issue Dec 24, 2021 · 6 comments
Open

Question: Skip recover functionality #267

vitalinfo opened this issue Dec 24, 2021 · 6 comments

Comments

@vitalinfo
Copy link

@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

@mvz
Copy link
Contributor

mvz commented Dec 24, 2021

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.

@vitalinfo
Copy link
Author

@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.

@mvz
Copy link
Contributor

mvz commented Dec 28, 2021

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

@vitalinfo
Copy link
Author

@mvz yes, this will work, but if user model has a lot of associations, the recover complexity will be huge

@mvz
Copy link
Contributor

mvz commented Dec 29, 2021

@vitalinfo and how will this feature help with that? What would the code look like?

@vitalinfo
Copy link
Author

I'll do this feature, in worse case I'll use fork in my project

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants