pinia-orm
pinia-orm copied to clipboard
fresh() doesn't call any lifecycle Hook
Environment
No response
Reproduction
Describe the bug
I need to listen for the lifecycle hook inside the Model when the fresh() is called , but no any lifecycle hook is listening to fresh() while if i use save() it works
For now i'm using this as a workaround
const repo = useRepo(REPO_NAME)
// clear everything
repo.flush()
// then save , i.e to trigger the lifecycle
repo.save(NEW_DATA)
ideally fresh() should also be a lifecycle hook trigger
Additional context
No response
Logs
No response
Actually, it can be useful, if you have one mutator that doesn't trigger the hooks. For example, if you need to save raw data from a backend.
@harmyderoman I agree with you , But the issue is that in most cases we need to check the hooks ( as we're using saving
and other hooks for other functions )
May be we can add an optional raw parameter like {raw:true} as the last config object and if raw is true we can keep it as it is , otherwise we can listen for the hooks
Hmmm interesting. I try to get my thoughts around that. You both have valid points. I think flush is getting hooks and i also add the option to avoid hooks.