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

Commit 609e8aed by Luca Moser

Updates hooks.md

Fixes the wrong arguments in the example in the hooks documentation.
1 parent 095f2b75
Showing with 3 additions and 4 deletions
...@@ -143,10 +143,10 @@ afterBulkCreate / afterBulkUpdate / afterBulkDestroy ...@@ -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. If you want to emit hooks for each individual record, along with the bulk hooks you can pass `individualHooks: true` to the call.
```js ```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 // 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 // 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 ...@@ -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 }`. 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. 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
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!