code: func (m *GormIterationRepository) Save(ctx context.Context, i Iteration) (*Iteration, error) {
  	itr := Iteration{}
  	tx := m.db.Where("id=?", i.ID).First(&itr)
  	if tx.RecordNotFound() {
  		log.Error(ctx, map[string]interface{}{
  			"iteration_id": i.ID,
  		}, "iteration cannot be found")
  		// treating this as a not found error: the fact that we're using number internal is implementation detail
  		return nil, errors.NewNotFoundError("iteration", i.ID.String())
  	}
  	if err := tx.Error; err != nil {
  		log.Error(ctx, map[string]interface{}{
  			"iteration_id": i.ID,
  			"err":          err,
  		}, "unknown error happened when searching the iteration")
  		return nil, errors.NewInternalError(ctx, err)
  	}
  	tx = tx.Save(&i)
  	if err := tx.Error; err != nil {
  		log.Error(ctx, map[string]interface{}{
  			"iteration_id": i.ID,
  			"err":          err,
  		}, "unable to save the iterations")
  		return nil, errors.NewInternalError(ctx, err)
  	}
  	return &i, nil
  }
docs: // Save updates the given iteration in the db. Version must be the same as the one in the stored version
  // returns NotFoundError, VersionConflictError or InternalError