-
Notifications
You must be signed in to change notification settings - Fork 2k
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
beforeDestroy & afterDestroy #957
Comments
As you said, you should be able to do a query to get the items that would be deleted in "beforeDestroy". Since the callback lives inside the model class file, you should know which model class to use!
|
I was trying to avoid using named models because when renaming or duplicating the model, I will need to modify the contents too. I was expecting something like:
|
I'm not sure I follow. The |
Yes, that I understood. Thanks for trying to help me understand! :-) Since I am in the context of modifying something, I would expect to have a simple way to identify it like I was trying to do the following:
Also if I ever think about renaming I am happy to create workarounds but if there is a solution to identify the models name without hard coding it into the source code, I would love to know it :-) |
@ifavo if you assign a var to the module.export, like so: var self = module.exports = {}; you can use |
Good idea, @Thomasdezeeuw. In fact, you don't even need the |
afterDestroy on the docs has the destroyed record in the params http://sailsjs.org/#/documentation/concepts/ORM/Lifecyclecallbacks.html?q=callbacks-on-destroy |
@gadelkareem that's because now Sails version is the 0.10.x and this issue is from 0.9 or maybe from an earlier version... |
hmm.. I am using sails 0.10.x and afterDestroy does not return record as per docs |
Strange, this is working fine for me, i'm using 0.10.5 |
Hi!
I am trying to make a use of before- and afterDestroy on the models but I am struggling to get the object instance that is being destroyed.
How can I get the current dataset that is being deleted? With the criteria on the beforeDestroy function I could do a database query but for this I am missing the classname.
Thanks!
Mario
The text was updated successfully, but these errors were encountered: