I'm using gorm as a Golang ORM. I need to detect if any model field has changed to trigger a update on a thirdy-party API service.
I have tried to test every field with an If statement, but it gets ugly when the model has many fields.
var person Person
db.Where("id = ?", id).First(&person)
if person.Name != body.Person.Name || person.Age != body.Person.Age {
// Trigger API update
}
db.Save(&person)
Is there a easy way to achieve this?