Version: v0.0.0-...-b472bfd Latest Latest

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

Go to latest
Published: Jul 27, 2021 License: Apache-2.0 Imports: 6 Imported by: 0



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



This section is empty.


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

Set of error variables for CRUD operations.


This section is empty.


type City

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

City represents a city and its coordinates.

type Store

type Store struct {
	// contains filtered or unexported fields

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

func NewStore

func NewStore(log *log.Logger, gql *graphql.GraphQL) Store

NewStore constructs a city store for api access.

func (Store) QueryByID

func (s Store) QueryByID(ctx context.Context, traceID string, cityID string) (City, error)

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

func (Store) QueryByName

func (s Store) QueryByName(ctx context.Context, traceID string, name string) (City, error)

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

func (Store) QueryNames

func (s Store) QueryNames(ctx context.Context, traceID string) ([]string, error)

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

func (Store) Upsert

func (s Store) Upsert(ctx context.Context, traceID string, cty City) (City, error)

Upsert adds a new city to the database if it doesn't already exist by name. If the city already exists in the database, the function will return an City value with the existing id.

Source Files

Jump to

Keyboard shortcuts

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