data

package
v0.0.0-...-0a87df9 Latest Latest
Warning

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

Go to latest
Published: Jul 25, 2023 License: GPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrRecordNotFound = errors.New("record not found")
	ErrEditConflict = errors.New("edit conflict")
)
View Source
var ErrRecordNotFound = errors.New("record not found")

Functions

func ValidateFilters

func ValidateFilters(v *validator.Validator, f Filters)

Types

type Country

type Country struct {
	Name         name                   `json:"name"`
	Tld          []string               `json:"tld,omitempty"`
	CCA2         string                 `json:"cca2,omitempty"`
	CCN3         string                 `json:"ccn3,omitempty"`
	CCA3         string                 `json:"cca3,omitempty"`
	CIOC         string                 `json:"cioc,omitempty"`
	Independent  bool                   `json:"independent,omitempty"`
	Status       string                 `json:"status,omitempty"`
	UNMember     bool                   `json:"unMember,omitempty"`
	Currencies   map[string]currency    `json:"currencies,omitempty"`
	IDD          *idd                   `json:"idd,omitempty"`
	Capital      []string               `json:"capital,omitempty"`
	AltSpellings []string               `json:"altSpellings,omitempty"`
	Region       string                 `json:"region,omitempty"`
	SubRegion    string                 `json:"subregion,omitempty"`
	Languages    map[string]string      `json:"languages,omitempty"`
	Translations map[string]translation `json:"translations,omitempty"`
	LatLng       []float32              `json:"latlng,omitempty"`
	LandLocked   bool                   `json:"landlocked,omitempty"`
	Borders      []string               `json:"borders,omitempty"`
	Area         float32                `json:"area,omitempty"`
	Demonyms     map[string]demonyms    `json:"demonyms,omitempty"`
	Flag         string                 `json:"flag,omitempty"`
	Maps         map[string]string      `json:"maps,omitempty"`
	Population   int                    `json:"population,omitempty"`
	Gini         map[string]float32     `json:"gini,omitempty"`
	Fifa         string                 `json:"fifa,omitempty"`
	Car          car                    `json:"car,omitempty"`
	Timezones    []string               `json:"timezones,omitempty"`
	Continents   []string               `json:"continents,omitempty"`
	Flags        graphicsFormat         `json:"flags,omitempty"`
	CoatOfArms   *graphicsFormat        `json:"coatOfArms,omitempty"`
	StartOfWeek  string                 `json:"startOfWeek,omitempty"`
	CapitalInfo  *capitalInfo           `json:"capitalInfo,omitempty"`
	PostalCode   *postalCode            `json:"postalCode,omitempty"`
}

func (*Country) Scan

func (c *Country) Scan(value interface{}) error

func (Country) Value

func (c Country) Value() (driver.Value, error)

type CountryModel

type CountryModel struct {
	DB *sql.DB
}

func (*CountryModel) GetAll

func (c *CountryModel) GetAll(ctx context.Context, filters Filters) ([]*Country, Metadata, error)

func (CountryModel) GetByCapital

func (c CountryModel) GetByCapital(otelCtx context.Context, capital string) (*Country, error)

func (CountryModel) GetByCode

func (c CountryModel) GetByCode(otelCtx context.Context, code string) (*Country, error)

func (CountryModel) GetByCodes

func (c CountryModel) GetByCodes(otelCtx context.Context, codes []string) ([]*Country, error)

func (CountryModel) GetByCurrency

func (c CountryModel) GetByCurrency(otelCtx context.Context, currency string, filters Filters) ([]*Country, Metadata, error)

func (CountryModel) GetByDemonyms

func (c CountryModel) GetByDemonyms(otelCtx context.Context, demonyms string, filters Filters) ([]*Country, Metadata, error)

func (CountryModel) GetByLanguage

func (c CountryModel) GetByLanguage(otelCtx context.Context, language string, filters Filters) ([]*Country, Metadata, error)

func (*CountryModel) GetByName

func (c *CountryModel) GetByName(otelCtx context.Context, name string, filers Filters) ([]*Country, Metadata, error)

func (CountryModel) GetByRegion

func (c CountryModel) GetByRegion(otelCtx context.Context, region string, filters Filters) ([]*Country, Metadata, error)

func (CountryModel) GetBySubregion

func (c CountryModel) GetBySubregion(otelCtx context.Context, subregion string, filters Filters) ([]*Country, Metadata, error)

func (CountryModel) GetByTranslation

func (c CountryModel) GetByTranslation(otelCtx context.Context, translation string) (*Country, error)

type Filters

type Filters struct {
	Page     int
	PageSize int
}

type Item

type Item struct {
	ID      int
	Version int32
	Country Country
}

type Metadata

type Metadata struct {
	CurrentPage  int `json:"currentPage"`
	PageSize     int `json:"pageSize"`
	FirstPage    int `json:"firstPage"`
	LastPage     int `json:"lastPage"`
	TotalRecords int `json:"totalRecords"`
}

type Models

type Models struct {
	Countries CountryModel
}

func NewModels

func NewModels(db *sql.DB) Models

type OtelWrappedError

type OtelWrappedError struct {
	// contains filtered or unexported fields
}

func (*OtelWrappedError) Error

func (ot *OtelWrappedError) Error() string

func (*OtelWrappedError) Unwrap

func (ot *OtelWrappedError) Unwrap() error

func (*OtelWrappedError) WithSpanInfo

func (ot *OtelWrappedError) WithSpanInfo(ctx context.Context, err error) error

Jump to

Keyboard shortcuts

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