sas1024 / gorm-loggable

Loggable plugin for GORM
MIT License
28 stars 22 forks source link

Add skipping update event if no changes in struct #3

Closed sas1024 closed 6 years ago

sas1024 commented 6 years ago

It's need to prevent to write update log if fields in struct was not updated.

For now gorm:after_update callback is used for handling updates. If there is no updated fields in loggable struct, gorm will update updatedAt field.

What did I expect to see?

Loggable must skip these update events, if no updates in struct fields

What did I see instead?

Loggable write update event to database. And there is only one changed field - updatedAt.

-- May be gorm:before_update callback will help to solve this issue.