func (r *GormRepository) Create(ctx context.Context, space *Space) (*Space, error) {
	// We might want to create a space with a specific ID, e.g. space.SystemSpace
	if space.ID == uuid.Nil {
		space.ID = uuid.NewV4()
	}

	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") {
			return nil, errors.NewBadParameterError("Name", space.Name).Expected("unique")
		}
		return nil, errors.NewInternalError(err.Error())
	}

	log.Info(ctx, map[string]interface{}{
		"space_id": space.ID,
	}, "Space created successfully")
	return space, nil
}
// Create creates a new Space in the db
// returns BadParameterError or InternalError
Create creates a new Space in the db
returns BadParameterError or InternalError
// Create creates a new Space in the db // returns BadParameterError or InternalError
func (r *GormRepository) Create(ctx context.Context, space *Space) (*Space, error) {
	if space.ID == uuid.Nil {
		space.ID = uuid.NewV4()
	}
	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") {
			return nil, errors.NewBadParameterError("Name", space.Name).Expected("unique")
		}
		return nil, errors.NewInternalError(err.Error())
	}
	log.Info(ctx, map[string]interface{}{
		"space_id": space.ID,
	}, "Space created successfully")
	return space, nil
}
func ( r * GormRepository ) Create ( ctx context . Context , space * Space ) ( * Space , error ) { if space . ID == uuid . Nil { space . ID = uuid . NewV4 ( ) } tx := r . db . Create ( space ) if err := tx . Error ; err != nil { if gormsupport . IsCheckViolation ( tx . Error , " " ) { return nil , errors . NewBadParameterError ( " " , space . Name ) . Expected ( " " ) } if gormsupport . IsUniqueViolation ( tx . Error , " " ) { return nil , errors . NewBadParameterError ( " " , space . Name ) . Expected ( " " ) } return nil , errors . NewInternalError ( err . Error ( ) ) } log . Info ( ctx , map [ string ] interface { } { " " : space . ID , } , " " ) return space , nil }
Create creates a new Space in the db
returns BadParameterError or InternalError
Create creates a new Space in the db returns BadParameterError or InternalError
// We might want to create a space with a specific ID, e.g. space.SystemSpace