afterSave hook empty $dirty property
Closed this issue · 2 comments
Package version
21.5.1
Describe the bug
Property $dirty
is empty on after hooks (afterSave). This works fine on beforeSave
hook.
This worked fine in older releases of Adonis.js 4.1.
Reproduction repo
No response
I believe this might be intentional. You can find similar behavior in other frameworks, like Laravel.
The $dirty
property keeps track of attributes that have changed compared to their original values. However, once you save the model, those changes are committed, and the attributes now match their original values. As a result, there are no longer any "dirty" attributes to track.
lucid/src/orm/base_model/index.ts
Lines 1369 to 1414 in ca67d8d
I would recommend storing the dirty values before saving if you need them later in the code.
I believe this might be intentional. You can find similar behavior in other frameworks, like Laravel.
The
$dirty
property keeps track of attributes that have changed compared to their original values. However, once you save the model, those changes are committed, and the attributes now match their original values. As a result, there are no longer any "dirty" attributes to track.lucid/src/orm/base_model/index.ts
Lines 1369 to 1414 in ca67d8d
I would recommend storing the dirty values before saving if you need them later in the code.
Thank you for explanation.