不要怂,就是干,撸起袖子干!

Commit 63e80554 by Matt Broadstone

refactor Hooks mixin

The existing Hooks mixin explicitly defines methods for all hooks on
the Sequelize instance or a given Model. This modifies the Hooks module
to provide a single method "applyTo", which mixes in the base Hook
functionality (addHook, runHooks, etc), as well as autogenerates
declarative hooks for the object its mixing in to (Model.beforeCreate,
Sequelize.beforeDefine, etc).
1 parent 5bc2d11c
......@@ -2179,7 +2179,7 @@ module.exports = (function() {
};
Utils._.extend(Model.prototype, associationsMixin);
Utils._.extend(Model.prototype, Hooks);
Hooks.applyTo(Model);
return Model;
})();
......@@ -268,8 +268,7 @@ module.exports = (function() {
* Allow hooks to be defined on Sequelize + on sequelize instance as universal hooks to run on all models
* and on Sequelize/sequelize methods e.g. Sequelize(), Sequelize#define()
*/
Utils._.extend(Sequelize, Hooks);
Utils._.extend(Sequelize.prototype, Hooks);
Hooks.applyTo(Sequelize);
/**
* A general error class
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!