How to do conditional upsert in gorm?

Viewed 668

My go code for upserting a list of records using gorm upsert:

if err := appdb.GetDBCli().Clauses(gormclause.OnConflict{
        Columns:   []gormclause.Column{{Name: "user_uuid"}, {Name: "node_id"}, {Name: "class_uuid"}},
        DoUpdates: gormclause.AssignmentColumns([]string{"current", "status", "content", "description", "remark", "attributes"}),
    }).Create(records).Error; err != nil {
        return nil, apperr.DbQueryError
    }

How do I make it possible for gorm to NOT update the description column, and just ignore the value, if there is a conflict and the record.description being saved is an empty string?

0 Answers
Related