planet

package
v0.0.0-...-c9fd9d4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 21, 2022 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Planet

type Planet struct {
	Name        string
	Distance    int
	Temperature int
	CreatedAt   time.Time
}

type PlanetService

type PlanetService interface {
	GetAllPlanets() ([]Planet, error)
	GetPlanet(ID uint) (Planet, error)
	AddPlanet(planet Planet) (Planet, error)
	UpdatePlanet(ID uint, updatedPlanet Planet) (Planet, error)
	DeletePlanet(ID uint) error
}

type Service

type Service struct {
	Database *gorm.DB
}

func NewService

func NewService(database *gorm.DB) *Service

Returns a new Planet service

func (*Service) AddPlanet

func (s *Service) AddPlanet(planet Planet) (Planet, error)

Adds a new planet to the database

func (*Service) DeletePlanet

func (s *Service) DeletePlanet(ID uint) error

Delete a planet from the database

func (*Service) GetAllPlanets

func (s *Service) GetAllPlanets() ([]Planet, error)

Returns all planets in the database

func (*Service) GetPlanet

func (s *Service) GetPlanet(ID uint) (Planet, error)

Returns a planet for ID

func (*Service) UpdatePlanet

func (s *Service) UpdatePlanet(ID uint, updatedPlanet Planet) (Planet, error)

Update an existing planet in the database

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL