Documentation ¶
Index ¶
- type CityList
- type CityListDB
- func (r *CityListDB) Create(city cities.CityRequest) (string, error)
- func (r *CityListDB) Delete(id int) error
- func (r *CityListDB) GetFromDistrict(district string) ([]string, error)
- func (r *CityListDB) GetFromFoundation(start, end int) ([]string, error)
- func (r *CityListDB) GetFromPopulation(start, end int) ([]string, error)
- func (r *CityListDB) GetFromRegion(region string) ([]string, error)
- func (r *CityListDB) GetFull(id int) (*cities.City, error)
- func (r *CityListDB) SetPopulation(id, population int) error
- type DataBase
- type Repository
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CityList ¶
type CityList interface { Create(city cities.CityRequest) (string, error) Delete(id int) error SetPopulation(id, population int) error GetFromRegion(region string) ([]string, error) GetFromDistrict(district string) ([]string, error) GetFromPopulation(start, end int) ([]string, error) GetFromFoundation(start, end int) ([]string, error) GetFull(id int) (*cities.City, error) // contains filtered or unexported methods }
type CityListDB ¶
type CityListDB struct {
// contains filtered or unexported fields
}
func NewCityListDB ¶
func NewCityListDB(db *DataBase) *CityListDB
func (*CityListDB) Create ¶
func (r *CityListDB) Create(city cities.CityRequest) (string, error)
Create places a new city in the database and assigns it an id. Returns the id of the city
func (*CityListDB) Delete ¶
func (r *CityListDB) Delete(id int) error
Delete deletes the city with the id from the database
func (*CityListDB) GetFromDistrict ¶
func (r *CityListDB) GetFromDistrict(district string) ([]string, error)
GetFromDistrict returns the list of cities by district
func (*CityListDB) GetFromFoundation ¶
func (r *CityListDB) GetFromFoundation(start, end int) ([]string, error)
GetFromFoundation returns the list of cities by foundation
func (*CityListDB) GetFromPopulation ¶
func (r *CityListDB) GetFromPopulation(start, end int) ([]string, error)
GetFromPopulation returns the list of cities by population
func (*CityListDB) GetFromRegion ¶
func (r *CityListDB) GetFromRegion(region string) ([]string, error)
GetFromRegion returns the list of cities by region
func (*CityListDB) GetFull ¶
func (r *CityListDB) GetFull(id int) (*cities.City, error)
GetFull searches for a city by id. If successful, it returns full information about the city
func (*CityListDB) SetPopulation ¶
func (r *CityListDB) SetPopulation(id, population int) error
SetPopulation updates the city population by id in the database
type DataBase ¶
type DataBase struct {
// contains filtered or unexported fields
}
DataBase contains a list of cities, and the last free identifier
func NewDataBase ¶
NewDataBase creates a database. Opens a csv file and copies the data into the DataBase structure. If successful, it returns *DataBase
type Repository ¶
type Repository struct {
CityList
}
func NewRepository ¶
func NewRepository(db *DataBase) *Repository