city

package
v0.0.0-...-26aeaf7 Latest Latest
Warning

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

Go to latest
Published: Dec 6, 2024 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package city provides support for managing city data in the database.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrExists   = errors.New("city exists")
	ErrNotFound = errors.New("city not found")
)

Set of error variables for CRUD operations.

Functions

This section is empty.

Types

type City

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

City manages the set of API's for city access.

func New

func New(log *log.Logger, gql *graphql.GraphQL) City

New constructs a City for api access.

func (City) Add

func (c City) Add(ctx context.Context, traceID string, cty Info) (Info, error)

Add adds a new city to the database. If the city already exists this function will fail but the found city is returned. If the city is being added, the city with the id from the database is returned.

func (City) QueryByID

func (c City) QueryByID(ctx context.Context, traceID string, cityID string) (Info, error)

QueryByID returns the specified city from the database by the city id.

func (City) QueryByName

func (c City) QueryByName(ctx context.Context, traceID string, name string) (Info, error)

QueryByName returns the specified city from the database by the city name.

func (City) QueryNames

func (c City) QueryNames(ctx context.Context, traceID string) ([]string, error)

QueryNames returns the list of city names currently loaded in the database.

type Info

type Info struct {
	ID   string  `json:"id,omitempty"`
	Name string  `json:"name"`
	Lat  float64 `json:"lat"`
	Lng  float64 `json:"lng"`
}

Info represents a city and its coordinates.

Jump to

Keyboard shortcuts

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