repository

package
v0.0.0-...-7dd5076 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2022 License: Unlicense Imports: 5 Imported by: 0

Documentation

Index

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

func NewDataBase(filePath string) (*DataBase, error)

NewDataBase creates a database. Opens a csv file and copies the data into the DataBase structure. If successful, it returns *DataBase

func (*DataBase) SaveCSV

func (db *DataBase) SaveCSV(filePath string) error

SaveCSV saves the database to a csv file. Creates a csv file and copies data from the DataBase structure into it. If successful, overwrites the csv file into the filePath file.

type Repository

type Repository struct {
	CityList
}

func NewRepository

func NewRepository(db *DataBase) *Repository

Jump to

Keyboard shortcuts

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