func (s SqlPreferenceStore) update(transaction *gorp.Transaction, preference *model.Preference) StoreResult { result := StoreResult{} if _, err := transaction.Update(preference); err != nil { result.Err = model.NewAppError("SqlPreferenceStore.update", "We couldn't update the preference", "user_id="+preference.UserId+", category="+preference.Category+", name="+preference.Name+", "+err.Error()) } return result }
func executeSql(trans *gorp.Transaction, tableName string, status Store, tableCtx Store) { for k, v := range status { switch v.(int) { case STATUS_UPDATE: fmt.Println("STATUS_UPDATE: ", reflect.ValueOf(tableCtx[k]).Elem().FieldByName("Data").Interface()) _, err := trans.Update(reflect.ValueOf(tableCtx[k]).Elem().FieldByName("Data").Interface()) if err != nil { panic(err.Error()) } case STATUS_DELETE: _, err := trans.Exec(fmt.Sprintf("DELETE FROM `%s` WHERE `uuid`='%s'", tableName, k)) if err != nil { panic(err.Error()) } case STATUS_CREATE: err := trans.Insert(reflect.ValueOf(tableCtx[k]).Elem().FieldByName("Data").Interface()) if err != nil { panic(err.Error()) } } } }