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

Commit cfba87fe by Mick Hansen

Merge pull request #3507 from XemsDoom/fix-hook-doc

Updates hooks.md
2 parents 095f2b75 609e8aed
Showing with 3 additions and 4 deletions
......@@ -143,10 +143,10 @@ afterBulkCreate / afterBulkUpdate / afterBulkDestroy
If you want to emit hooks for each individual record, along with the bulk hooks you can pass `individualHooks: true` to the call.
```js
Model.destroy({ where: {accessLevel: 0}}, {individualHooks: true})
Model.destroy({ where: {accessLevel: 0}, individualHooks: true})
// Will select all records that are about to be deleted and emit before- + after- Destroy on each instance
Model.update({username: 'Toni'}, { where: {accessLevel: 0}}, {individualHooks: true})
Model.update({username: 'Toni'}, { where: {accessLevel: 0}, individualHooks: true})
// Will select all records that are about to be updated and emit before- + after- Update on each instance
```
......@@ -267,4 +267,4 @@ If we had not included the transaction option in our call to `User.update` in th
It is very important to recognize that sequelize may make use of transactions internally for certain operations such as `Model.findOrCreate`. If your hook functions execute read or write operations that rely on the object's presence in the database, or modify the object's stored values like the example in the preceding section, you should always specify `{ transaction: options.transaction }`.
If the hook has been called in the process of a transacted operation, this makes sure that your dependent read/write is a part of that same transaction. If the hook is not transacted, you have simply specified `{ transaction: null }` and can expect the default behaviour.
\ No newline at end of file
If the hook has been called in the process of a transacted operation, this makes sure that your dependent read/write is a part of that same transaction. If the hook is not transacted, you have simply specified `{ transaction: null }` and can expect the default behaviour.
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!