db

package
v0.0.0-...-2b0b049 Latest Latest
Warning

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

Go to latest
Published: Dec 17, 2019 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type API

type API interface {
	SitesGet(ctx context.Context, id uint64) ([]*pb.Site, error)
	SiteUpsert(ctx context.Context, latitude float32, longitude float32, nationalForestID uint64, districtID uint64, altitude uint64, notes string) (*pb.Site, error)
	NationalForestsGet(ctx context.Context, id uint64) ([]*pb.NationalForest, error)
	DistrictsGet(ctx context.Context, id uint64) ([]*pb.District, error)
}

API is the interface that the DB struct fulfills, with the methods to interact with DB. It exists to allow mocking of this package.

type DB

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

func New

func New(username, password, schemaName, host, port string) (*DB, error)

New returns an instantiated DB or an error if the database connection parameters don't work or it can not connect.

func (*DB) Close

func (d *DB) Close() error

Close permanently closes the database connection

func (*DB) DistrictsGet

func (d *DB) DistrictsGet(ctx context.Context, id uint64) ([]*pb.District, error)

DistrictsGet retrieves all districts

func (*DB) Migrate

func (d *DB) Migrate(migrateDir string) error

Migrate will perform any necessary migrations on the database

func (*DB) NationalForestsGet

func (d *DB) NationalForestsGet(ctx context.Context, id uint64) ([]*pb.NationalForest, error)

NationalForestsGet retrieves all national forests

func (*DB) SiteUpsert

func (d *DB) SiteUpsert(ctx context.Context, latitude float32, longitude float32, nationalForestID uint64, districtID uint64, altitude uint64, notes string) (*pb.Site, error)

SiteUpsert updates or creates a site

func (*DB) SitesGet

func (d *DB) SitesGet(ctx context.Context, id uint64) ([]*pb.Site, error)

GetSites returns all campsites

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