store

package
v0.0.0-...-0dca507 Latest Latest
Warning

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

Go to latest
Published: Dec 18, 2021 License: GPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const DataCollection = "data"

DataCollection is mongodb collection name for data.

View Source
const ProjectCollection = "project"

ProjectCollection is mongodb collection name for project.

View Source
const ThingCollection = "thing"

ThingCollection is mongodb collection name for things.

Variables

This section is empty.

Functions

This section is empty.

Types

type Data

type Data struct {
	DB *mongo.Database
}

Data store handles database communication for data elements.

func New

func New(db *mongo.Database) *Data

New creates new data store.

func (Data) Fetch

func (d Data) Fetch(ctx context.Context, since, until, offset, limit int64, ids []string) ([]model.Data, error)

Fetch fetches given things data in given time range and sorts it. it uses disk for sort and etc.

func (*Data) Insert

func (d *Data) Insert(ctx context.Context, i model.Data) error

Insert given instance of data into database.

func (Data) PerProjectCount

func (d Data) PerProjectCount(ctx context.Context, projectID string) (map[string]int, error)

PerProjectCount counts number of records for given project per things it returns a map between thing identification and number of records for that thing.

type Project

type Project struct {
	DB *mongo.Database
}

Project stores and retrieves projects collection.

func (Project) Create

func (ps Project) Create(ctx context.Context, p model.Project) error

func (Project) Delete

func (ps Project) Delete(ctx context.Context, id string) error

func (Project) Get

func (ps Project) Get(ctx context.Context, id string) (model.Project, error)

func (Project) List

func (ps Project) List(ctx context.Context) ([]model.Project, error)

List returns all registered projects.

func (Project) Logs

func (ps Project) Logs(ctx context.Context, name string, limit int) ([]model.ProjectLog, error)

func (Project) Update

func (ps Project) Update(ctx context.Context, id string, fields map[string]interface{}) (model.Project, error)

type Thing

type Thing struct {
	DB *mongo.Database
}

Thing stores and retrieves things collection.

func (Thing) Create

func (ts Thing) Create(ctx context.Context, t model.Thing) error

Create creates the given thing in things collection.

func (Thing) GetByName

func (ts Thing) GetByName(ctx context.Context, id string) (model.Thing, error)

GetByName returns the thing that has given identification.

func (Thing) GetByProjectID

func (ts Thing) GetByProjectID(ctx context.Context, pid string) ([]model.Thing, error)

GetByProjectID returns all things that are associated with given project identification.

func (Thing) Remove

func (ts Thing) Remove(ctx context.Context, id string) error

Remove removes the given thing from the things collection.

func (Thing) Update

func (ts Thing) Update(ctx context.Context, id string, m *string, s *bool) (model.Thing, error)

Update update the given thing's model.

Jump to

Keyboard shortcuts

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