place

package
v0.0.0-...-01d1cd0 Latest Latest
Warning

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

Go to latest
Published: Jan 28, 2022 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

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

Index

Constants

This section is empty.

Variables

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

Set of error variables for CRUD operations.

Functions

This section is empty.

Types

type City

type City struct {
	ID string `json:"id"`
}

City is used to capture the city id in relationships.

type Place

type Place struct {
	ID               string   `json:"id,omitempty"`
	Category         string   `json:"category"`
	City             City     `json:"city"`
	PlaceID          string   `json:"place_id"`
	CityName         string   `json:"city_name"`
	Name             string   `json:"name"`
	Address          string   `json:"address"`
	Lat              float64  `json:"lat"`
	Lng              float64  `json:"lng"`
	LocationType     []string `json:"location_type"`
	AvgUserRating    float32  `json:"avg_user_rating"`
	NumberOfRatings  int      `json:"no_user_rating"`
	GmapsURL         string   `json:"gmaps_url"`
	PhotoReferenceID string   `json:"photo_id"`
}

Place contains the place data points captured from the API.

type Store

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

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

func NewStore

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

NewStore constructs a place store for api access.

func (Store) QueryByCategory

func (s Store) QueryByCategory(ctx context.Context, traceID string, category string) ([]Place, error)

QueryByCategory returns the collection of places from the database by the cagtegory name.

func (Store) QueryByCity

func (s Store) QueryByCity(ctx context.Context, traceID string, cityID string) ([]Place, error)

QueryByCity returns the collection of places from the database by the city id.

func (Store) QueryByID

func (s Store) QueryByID(ctx context.Context, traceID string, placeID string) (Place, error)

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

func (Store) QueryByName

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

QueryByName returns the specified place from the database by name.

func (Store) Upsert

func (s Store) Upsert(ctx context.Context, traceID string, plc Place) (Place, error)

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

Jump to

Keyboard shortcuts

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