I have a function which is creating a record something like this:
func A(db *gorm.DB, b []C) error {
d := []e{}
for _, f := range b {
d = append(d, g(f))
}
return db.Save(&d).Error
}
I want to be able to upload some data (which could potentially be the same), but I’d wish only the differences to be saved.
So if I upload the same data, I’d want that to happen without any problem, as there are no differences (or changes).
If I try to upload the same data, I get: "error":"Error 1062: Duplicate entry '1' for key ...
but as mentioned earlier, I would not want this to happen. I’d wish this to get uploaded without any error.
I also did something like Upsert / On Conflict, but it didn’t work (Create | GORM - The fantastic ORM library for Golang, aims to be developer friendly.)
Thanks!