place

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: 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 (
	ErrExists   = errors.New("place exists")
	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 Info

type Info 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"`
}

Info contains the place data points captured from the API.

type Place

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

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

func New

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

New constructs a Place for api access.

func (Place) Add

func (p Place) Add(ctx context.Context, traceID string, plc Info) (Info, error)

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

func (Place) QueryByCategory

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

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

func (Place) QueryByCity

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

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

func (Place) QueryByID

func (p Place) QueryByID(ctx context.Context, traceID string, placeID string) (Info, error)

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

func (Place) QueryByName

func (p Place) QueryByName(ctx context.Context, traceID string, name string) (Info, error)

QueryByName returns the specified place from the database by name.

Jump to

Keyboard shortcuts

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