storage

package
v0.0.0-...-771faf5 Latest Latest
Warning

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

Go to latest
Published: Sep 3, 2024 License: AGPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrAlreadyExists error = fmt.Errorf("thing already exists")
View Source
var ErrNotExist error = fmt.Errorf("thing does not exists")

Functions

This section is empty.

Types

type Condition

type Condition struct {
	ID           string
	Types        []string
	ThingID      string
	Offset       int
	Limit        int
	Tenants      []string
	Measurements bool
	State        bool
}

func NewCondition

func NewCondition(conditions ...ConditionFunc) *Condition

func (Condition) NamedArgs

func (c Condition) NamedArgs() pgx.NamedArgs

func (Condition) Validate

func (c Condition) Validate(fn func(c Condition) bool) error

func (Condition) Where

func (c Condition) Where() string

type ConditionFunc

type ConditionFunc func(*Condition) *Condition

func WithID

func WithID(id string) ConditionFunc

func WithLimit

func WithLimit(limit int) ConditionFunc

func WithMeasurements

func WithMeasurements(withMeasurments string) ConditionFunc

func WithOffset

func WithOffset(offset int) ConditionFunc

func WithState

func WithState(withState string) ConditionFunc

func WithTenants

func WithTenants(tenants []string) ConditionFunc

func WithThingID

func WithThingID(thingID string) ConditionFunc

func WithType

func WithType(types []string) ConditionFunc

type Config

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

func LoadConfiguration

func LoadConfiguration(ctx context.Context) Config

func NewConfig

func NewConfig(host, user, password, port, dbname, sslmode string) Config

func (Config) ConnStr

func (c Config) ConnStr() string

type Db

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

func New

func New(ctx context.Context, cfg Config) (Db, error)

func (Db) AddRelatedThing

func (db Db) AddRelatedThing(ctx context.Context, v []byte, conditions ...ConditionFunc) error

func (Db) CreateThing

func (db Db) CreateThing(ctx context.Context, v []byte) error

func (Db) QueryThings

func (db Db) QueryThings(ctx context.Context, conditions ...ConditionFunc) (QueryResult, error)

func (Db) RetrieveRelatedThings

func (db Db) RetrieveRelatedThings(ctx context.Context, conditions ...ConditionFunc) ([]byte, error)

func (Db) RetrieveThing

func (db Db) RetrieveThing(ctx context.Context, conditions ...ConditionFunc) ([]byte, string, error)

func (Db) UpdateThing

func (db Db) UpdateThing(ctx context.Context, v []byte) error

type QueryResult

type QueryResult struct {
	Things     []byte
	Count      int
	Limit      int
	Offset     int
	TotalCount int64
}

Jump to

Keyboard shortcuts

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