-
Notifications
You must be signed in to change notification settings - Fork 605
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
Call beforeUpdate, beforeDestroy, beforeValidate callbacks with criteria #1122
Conversation
Not forgotten! At a glance this looks pretty good. Will need more review, but as far as I'm concerned this is crucial to the next Waterline release. |
LGTM +1 |
@particlebanana is this good for the next release? |
Any plan to integrate this any time soon? |
Same question here, any integration plans for this? I'm already using the fork in one of my projects. Thanks a lot, @mmiller42 ! |
Would love to see this get merged, a great addition! |
+1 |
This is accepted into the |
Really looking forward to having this merged. Being able to look up the current state of the database entry (for doing comparisons during lifecycle validations) is very important in my everyday workflow. |
@mmiller42 Nice work. This is a great solution, and I appreciate you taking the time to implement backwards compatibility. I'm a little concerned about using beforeValidate: function (options, cb) {
// options.criteria;
// options.values;
} This last approach is the cleanest IMO, since it would allow us to pass custom metadata sent using the new There will be other breaking changes in the next release of core waterline adapters (related to case insensitivity), so it seems like as good a time as any to go ahead and make that kind of a change. @mmiller42 would you be willing / have time to adapt this to use the approach of an Thanks! |
I started down this path. It didn't end too well. Because it's backwards-incompatible, involves quite the change -- rewriting the method signatures of ~200 different unit tests. |
closed w/o comment? |
I'm guessing because I didn't convert the params to the options dictionary like as was suggested. It's a very intensive change that affects hundreds of unit tests. If anyone wants to complete this, I'm happy to grant access to my fork -- I don't have the time. It also makes this PR a huge thing for the Waterline team to review. That said, while maybe this isn't ready to be merged, should it be closed? Honestly it seems like a really necessary feature for Waterline. |
Hmm I didn't close this, I deleted the outdated branch that it was a PR against though. |
If you want to re-open against master that would be groovy. We can link back here. |
@mmiller42 Could you create a new PR? I think that knowing what is going to get updated is very useful (I'm finding myself in need of this functionality right now). |
Created #1328 |
Pass criteria to the beforeUpdate, beforeDestroy, and beforeValidate callbacks, before the
callback
param.In beforeValidate callbacks, criteria is
null
for create operations.Serves as a solution to issue #1004.
NOTE: For backwards compatibility, it now checks if the beforeValidate or beforeCreate callback(s) only accept 3 arguments or beforeDestroy accepts only 2 and if so, passes the callback as the last argument and omits criteria.
Example usage and explanation: