db

package
v0.0.0-...-4652a81 Latest Latest
Warning

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

Go to latest
Published: Sep 9, 2020 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrClientIsNotInitialised = errors.New("client is not initialised")
	ErrDatabaseDoesntExist    = errors.New("database doesnt exist")
	ErrCantConnect            = errors.New("cant connect to db")
	ErrCantDisconnect         = errors.New("cant terminate db connection")
	ErrCollectioniIsNil       = errors.New("collection is nil")
)

Functions

func Connect

func Connect(uri string) (*mongo.Client, error)

Connect connect to db

func Disconnect

func Disconnect(client *mongo.Client) error

Disconnect terminate db connection

func GetCollection

func GetCollection(client *mongo.Client, database string, collection string) (*mongo.Collection, error)

GetCollection new database and collection unless exits

func GetCollectionNames

func GetCollectionNames(client *mongo.Client, databaseName string) ([]string, error)

GetCollectionNames returns collection names in given database

func GetIdentifiers

func GetIdentifiers(collection *mongo.Collection) ([]string, error)

GetIdentifiers returns all line identifiers in the collection

func InsertDataPointLine

func InsertDataPointLine(collection *mongo.Collection, line []DataPoint) error

InsertLine insert slice of data points

func InsertSingleDataPoint

func InsertSingleDataPoint(collection *mongo.Collection, dp DataPoint) error

InsertSingleDataPoint

func InsertSingleLine

func InsertSingleLine(collection *mongo.Collection, l Line) error

InsertSingleDataPoint

func InsertTable

func InsertTable(collection *mongo.Collection, table [][]DataPoint)

InsertTable insert double dimensional slice of datapoints

func IsConnected

func IsConnected(client *mongo.Client) error

IsConnected returns nil if can ping db

func RemoveCollection

func RemoveCollection(client *mongo.Client, database string, collection string) error

RemoveCollection

Types

type DataPoint

type DataPoint struct {
	Row string
	Col string
	Val string
}

DataPoint a single entry of data with row/col headers

func GetSingleDataPoint

func GetSingleDataPoint(collection *mongo.Collection, row string, col string) (DataPoint, error)

GetSingleDataPoint search collection for single match with row/col parameters and decode into a datapoint

type Line

type Line struct {
	Identifier string
	X          []string
	Y          []string
}

func GetSingleLine

func GetSingleLine(collection *mongo.Collection, identifier string) (Line, error)

GetSingleLine search for single line and return match

Jump to

Keyboard shortcuts

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