store

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

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

Go to latest
Published: Jul 11, 2022 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Client

func Client(ctx context.Context, address string) (*mongo.Client, error)

Client creates a DB client

func IsDuplicateError

func IsDuplicateError(err error) bool

IsDuplicateError checks if an error is a duplacte index error

func IsNotFoundError

func IsNotFoundError(err error) bool

IsNotFoundError checks if an error is no ducument error

Types

type Collections

type Collections struct {
	Projects   string `json:"projects"`
	Scenarios  string `json:"scenarios"`
	TestPlans  string `json:"testplans"`
	Executions string `json:"executions"`
}

Collections represent the various collections in the store

func (Collections) Validate

func (c Collections) Validate() error

Validate if all collections have been passed

type Config

type Config struct {
	Address     string      `json:"address"`
	DataBase    string      `json:"database"`
	Collections Collections `json:"collections"`
}

Config represents the Store coonection information

func (Config) Validate

func (c Config) Validate() error

Validate that the config object is correct

type Data

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

Data is used to manipulate the collections

func Collection

func Collection(dbName, collectionName string, client *mongo.Client, constraints []string) (*Data, error)

Collection creates a collection object for the DB

func (*Data) AddOne

func (d *Data) AddOne(ctx context.Context, data interface{}) error

AddOne adds an item to the data collection

func (*Data) Delete

func (d *Data) Delete(ctx context.Context, id string) error

Delete an item based on the item ID

func (*Data) Get

func (d *Data) Get(ctx context.Context, id string, item interface{}) error

Get returns a single item based on the item ID

func (*Data) GetAll

func (d *Data) GetAll(ctx context.Context, items interface{}, filterMap map[string][]string, sortBy string, reverse bool, count int, previousLastValue string) error

GetAll returns all the items from a collection

func (*Data) Update

func (d *Data) Update(ctx context.Context, id string, item interface{}) error

Update replaces the item with the given item ID with the provided one

Jump to

Keyboard shortcuts

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