db

package
v0.0.0-...-bd08887 Latest Latest
Warning

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

Go to latest
Published: Jul 22, 2021 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DB

type DB interface {
	// Manage spot
	AddSpot(ctx context.Context, details SpotDetails) (interface{}, error)
	GetSpot(ctx context.Context, spotName string) (*spot.Details, error)
	UpdateSpot(ctx context.Context, spotName string, update SpotDetails) (int64, int64, error)
	DeleteSpot(ctx context.Context, spotName string) (int64, error)
}

DB is the database interface All the accesses to the database are hidden here

func New

func New() (DB, error)

New creates the DB interface

type OutdoorsightDB

type OutdoorsightDB struct {
	core.DB
}

OutdoorsightDB is the structure holding the core DB

func (*OutdoorsightDB) AddSpot

func (ods *OutdoorsightDB) AddSpot(ctx context.Context, details SpotDetails) (interface{}, error)

AddSpot inserts a spot with all its details in database

func (*OutdoorsightDB) DeleteSpot

func (ods *OutdoorsightDB) DeleteSpot(ctx context.Context, spotName string) (int64, error)

DeleteSpot deletes a spot from database

func (*OutdoorsightDB) GetSpot

func (ods *OutdoorsightDB) GetSpot(ctx context.Context, spotName string) (*spot.Details, error)

GetSpot retrieves a given spot with its details from database

func (*OutdoorsightDB) UpdateSpot

func (ods *OutdoorsightDB) UpdateSpot(ctx context.Context, spotName string, sd SpotDetails) (int64, int64, error)

UpdateSpot updates a spot in database

type Route

type Route struct {
	Name        string `bson:"name,omitempty"`
	Level       string `bson:"level,omitempty"`
	Points      int    `bson:"points,omitempty"`
	Information string `bson:"information,omitempty"`
}

Route holds the information about a route

type SpotDetails

type SpotDetails struct {
	Name     string                 `bson:"name,omitempty"`
	Routes   []Route                `bson:"routes,omitempty"`
	Metadata map[string]interface{} `bson:"metadata,omitempty"`
}

SpotDetails is the database structure that holds the information about a spot We do not want to expose the database format to the world, so we redefine it.

Directories

Path Synopsis
Package mock_db is a generated GoMock package.
Package mock_db is a generated GoMock package.

Jump to

Keyboard shortcuts

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