MCPcopy
hub / github.com/sequelize/sequelize / addHook

Function addHook

lib/hooks.js:143–160  ·  view source on GitHub ↗

* 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)

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 2

getProxiedHooksFunction · 0.85
getHooksFunction · 0.85

Tested by

no test coverage detected