Hooks


Hooks are optional functions which will execute before/after certain model operation where you can modify the data. Hooks which are starts with before will trigger before the database operation and starts with before will trigger after the database operation.

All available Hooks List

  • afterInsert
  • beforeInsert
  • errorInsert
  • afterUpdate
  • beforeUpdate
  • errorUpdate
  • afterDelete
  • beforeDelete
  • errorDelete
For detailed documentation refer Gitlab Documentation

Examples

Validation Example 1 :


Hooks List

  1. beforeInsert
    • data : Data to be insert.
    • trx : Transaction object to do database operations.
  2. afterInsert
    • data : Inserted data.
    • trx : Transaction object to do database operations.
  3. errorInsert
    • err : Exception object.
    • data : Insert data.
    • trx : Transaction object to do database operations.
  4. beforeUpdate
    • data : Data to be update.
    • trx : Transaction object to do database operations.
  5. afterUpdate
    • data : Updated data.
    • trx : Transaction object to do database operations.
  6. errorUpdate
    • err : Exception object.
    • data : Update data.
    • trx : Transaction object to do database operations.
  7. beforeDelete
    • data : An object which contains the id of the row.
    • trx : Transaction object to do database operations.
  8. afterDelete
    • data : An object which contains the id of the row.
    • trx : Transaction object to do database operations.
  9. errorDelete
    • err : Exception object.
    • data : An object which contains the id of the row.
    • trx : Transaction object to do database operations.
  10. beforeInsertb
    • data : Array of data to be insert.
  11. afterInsertb
    • data : Inserted datas.
  12. errorInsertb
    • err : Exception object.
    • data : Insert datas.
  13. beforeUpdateb
    • data : Array of data to be update.
  14. afterUpdateb
    • data : Updated data.
    • trx : Transaction object to do database operations.
  15. errorUpdateb
    • err : Exception object.
    • data : Update data.
  16. beforeDeleteb
    • afterDeleteb
      • errorDeleteb
        • err : Exception object.
        • data : An object which contains the ids of the row.

      Subscribe to Our Newsletter

      Let us stretch your imagination

      Download App