In the UI layer, users will sometimes edit a record and then click save without actually having changed the record. In the service layer or UI layer, code will then update the last_updated_by field with the user's info. The data layer and the audit layer will see that the entity has changed and will update and audit it.
So my question is, how to prevent the saving of a record, if the main fields haven't really changed ?
I guess, in the service layer, we can check to see if the main entity has changed before updating the last_updated_by field. But I want to know if there is a way of doing that in the data layer, which will probably make the service layer a bit cleaner.
Is there a way of saying that some fields are audit fields and aren't really important when considering that the entity has changed? Or perhaps let the audit entity take care of putting in the user's info if the entity has changed, but then how do we pass in the user's info?
If you have pondered or used a particular solution, can you please share it?