db

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Jan 11, 2023 License: AGPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewSensorStore

func NewSensorStore(uri, databaseName string) (*sensorStore, error)

NewSensorStore creates a new sensor store

Types

type GeoJson

type GeoJson struct {
	Point       string    `bson:"type"`
	Coordinates []float64 `bson:"coordinates"`
}

GeoJson is the mongo gis data format

type Location

type Location struct {
	Lat float64 `bson:"lat"`
	Lon float64 `bson:"lon"`
}

Sensor represents a location with lat and lon

type Sensor

type Sensor struct {
	ID       primitive.ObjectID `bson:"_id,omitempty"`
	Name     string             `bson:"name"`
	Tags     []string           `bson:"tags"`
	Location *Location          `bson:"location"`
	GeoJson  *GeoJson           `bson:"geoJson"`
}

Sensor represents a sensor with meta-data

type SensorStore

type SensorStore interface {
	Add(ctx context.Context, sensor Sensor) (primitive.ObjectID, error)
	Update(ctx context.Context, sensor Sensor) error
	Delete(ctx context.Context, id primitive.ObjectID) error
	FindByID(ctx context.Context, id primitive.ObjectID) (*Sensor, error)
	FindByName(ctx context.Context, name string) (*Sensor, error)
	FindNearest(ctx context.Context, location Location) (*Sensor, error)
}

SensorStore represents the public interface of the sensorStore

Jump to

Keyboard shortcuts

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