Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func EnableCity ¶
func EnableCity(tx *gorm.DB, city CityEnabled) error
EnableCity creates an entry in cities_enabled table
func IsNotFoundError ¶
IsNotFoundError returns whether an error represents a "not found" error.
Types ¶
type City ¶
type City struct { ID json.Number `json:"id" gorm:"primary_key;unique_index"` // citylist can use floats as ID WTF Name string `json:"name" gorm:"type:varchar(100)"` State string `json:"state" gorm:"type:varchar(100)"` // SH / BW blabla Country string `json:"country" gorm:"type:varchar(3)"` // max ISO3 Coords struct { Latitude float64 `json:"lat" gorm:"column:lat"` Longitude float64 `json:"lon" gorm:"column:lon"` } `json:"coord" gorm:"embedded"` }
City reflects a City of openweathermap longest german city name is currently: Schmedeswurtherwesterdeich 26 chars.
func FindCitiesByName ¶
FindCitiesByName searches our storage by name dont use fmt to inject % tags, this is a sec vuln in databases
func FindCityByID ¶
FindCityByID returns a City by it's id, error or nil
func FindEnabledCityByID ¶
FindEnabledCityByID returns a City by it's id, error or nil
type CityEnabled ¶
type CityEnabled struct { ID json.Number `json:"id" gorm:"primary_key;unique_index"` // citylist can use floats as ID WTF Name string `json:"name" gorm:"type:varchar(100)"` State string `json:"state" gorm:"type:varchar(100)"` // SH / BW blabla Country string `json:"country" gorm:"type:varchar(3)"` // max ISO3 Coords struct { Latitude float64 `json:"lat" gorm:"column:lat"` Longitude float64 `json:"lon" gorm:"column:lon"` } `json:"coord" gorm:"embedded"` }
CityEnabled holds enabled cities we are going to use a second table `cities_enabled` as `cities` can get quite huge. the cities_enabled table is used to store "only" cities we are going to update this allows us fast selects without creating complex statistic tables (pg_statistics) we are not referencing *city to allow OneOnOne struct conversion
func FindEnabledCities ¶
func FindEnabledCities(tx *gorm.DB) ([]*CityEnabled, error)
FindEnabledCities returns all enabled cities
func (*CityEnabled) TableName ¶
func (ce *CityEnabled) TableName() string
TableName returns the TableName of our user
type CityNotFoundError ¶
type CityNotFoundError struct{}
CityNotFoundError represents when a user is not found.
func (CityNotFoundError) Error ¶
func (e CityNotFoundError) Error() string