sequelize/sequelize — pull request #2240 by overlookmotel (2014-09-05 09:27:30+00:00)
Title: Options passed to hooks

Hello all.

I've started work on altering hooks.

Here's what I'm planning to do:

1. Amend signature of hooks to pass in options
2. Create a transaction if `hooks` or `individualHooks` == true and one does not exist (much as `findOrCreate()` does)
3. Alter `runHooks`to allow hook functions not to return a result (which is then interpretted as a resolved promise)
4. Add hooks for `find()` and `findAll()`

This PR is my work so far, and covers only (1) at the moment. I'll add commits for the rest as I go. But before I go further, and write tests for (1), I thought I'd check with you all if this is the direction you wanted to go in.

Here are the changes I've made:

* All hooks are passed the `options` argument
* Any return value from hooks are ignored - `dao`/`daos` and `options` can be altered inside the hook by reference
* Other data to be passed to hooks (e.g. `where`) is added into the `options` object rather than being passed as a separate argument

This will break BC, but that seems like a neccesary evil.

Please give me comments before I continue...