code: func (r *GormRepository) Create(ctx context.Context, space *Space) (*Space, error) {
  	defer goa.MeasureSince([]string{"goa", "db", "space", "create"}, time.Now())
  	// We might want to create a space with a specific ID, e.g. space.SystemSpace
  	if space.ID == uuid.Nil {
  		space.ID = uuid.NewV4()
  	}
  
  	// Check if the used space template can create spaces
  	spaceTemplateRepo := spacetemplate.NewRepository(r.db)
  	templ, err := spaceTemplateRepo.Load(ctx, space.SpaceTemplateID)
  	if err != nil {
  		return nil, errors.NewNotFoundError("space template", space.SpaceTemplateID.String())
  	}
  	if !templ.CanConstruct {
  		return nil, errors.NewForbiddenError(fmt.Sprintf("space template %q (ID: %s) cannot create spaces", templ.Name, templ.ID))
  	}
  
  	tx := r.db.Create(space)
  	if err := tx.Error; err != nil {
  		if gormsupport.IsCheckViolation(tx.Error, "spaces_name_check") {
  			return nil, errors.NewBadParameterError("Name", space.Name).Expected("not empty")
  		}
  		if gormsupport.IsUniqueViolation(tx.Error, "spaces_name_idx") {
  			log.Error(ctx, map[string]interface{}{
  				"err":        err,
  				"space_name": space.Name,
  			}, "unable to create space because a space with the same name already exists for this user")
  			return nil, errors.NewDataConflictError(fmt.Sprintf("space already exists ( for this user ) : %s ", space.Name))
  		}
  		return nil, errors.NewInternalError(ctx, err)
  	}
  	log.Debug(ctx, map[string]interface{}{
  		"space_id": space.ID,
  	}, "Space created")
  	return space, nil
  }
docs: // Create creates a new Space in the db
  // returns BadParameterError or InternalError