I'm trying to work out what the best way to check if the values that I'm saving have overwritten any that are in the database.
Obviously, I can get a record, compare the data and then save if it's different, but I wondered if there was a way to know inherently when a Save is done?
I can use update - and it will give back a row affected value > 1 but the problem with that is that update can't update a value in the db to a Go default type value (0 for example) therefore that won't work for this case.
For example:
db.Table("object").Where("id = ?", obj).Save(obj)
log.Println(res.RowsAffected) // always equals 1
compared to
res := db.Table("object").Where("id = ?", obj).Update(obj)
log.Println(res.RowsAffected) // equals 1 if updated
Any ideas?