* Add a hook to the model * * @param {string} hookType hook name @see {@link hookTypes} * @param {string|Function} [name] Provide a name for the hook function. It can be used to remove the hook later or to order hooks based on some sort of priority system in the future. * @param
(hookType, name, fn)
| 141 | * @memberof Sequelize.Model |
| 142 | */ |
| 143 | addHook(hookType, name, fn) { |
| 144 | if (typeof name === 'function') { |
| 145 | fn = name; |
| 146 | name = null; |
| 147 | } |
| 148 | |
| 149 | debug(`adding hook ${hookType}`); |
| 150 | // check for proxies, add them too |
| 151 | hookType = getProxiedHooks(hookType); |
| 152 | |
| 153 | hookType.forEach(type => { |
| 154 | const hooks = getHooks(this, type); |
| 155 | hooks.push(name ? { name, fn } : fn); |
| 156 | this.options.hooks[type] = hooks; |
| 157 | }); |
| 158 | |
| 159 | return this; |
| 160 | }, |
| 161 | |
| 162 | /** |
| 163 | * Remove hook from the model |
nothing calls this directly
no test coverage detected