Sequelize hooks not triggering when updating records manually

Javed IN :

I am new to sequelize and RDBMS, I have added sequelize hook as follows

bills.afterBulkUpdate((instance, options) => {
  console.log(instance);
});

I have questions here If I update any record in bills table manually(using DB script or query or triggers) Do this update will trigger bills.afterBulkUpdate hook declared?

Deep Kakkar :

Hooks (also known as callbacks or lifecycle events) are functions that are called before and after calls in sequelize are executed.

So as per your code, you are using afterBulkCreate(name, fn) ( link ) which is identified as A hook that is run after creating instances in bulk.

It should work after trigger the hook, It depends on how you have declared and used in your code.

For more details on hooks you can see its official documentation

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=29991&siteId=1