db

package
v0.0.0-...-fbf9a92 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidDBProvided = errors.New("invalid DB provided")

ErrInvalidDBProvided is returned in the event that an uninitialized db is used to perform actions against.

Functions

func Deleted

func Deleted() func(*ListOpts)

func Limit

func Limit(i int) func(*ListOpts)

func NewListOpts

func NewListOpts() []func(*ListOpts)

func Offset

func Offset(i int) func(*ListOpts)

func Org

func Org(i string) func(*ListOpts)

func Query

func Query(value interface{}) string

Query provides a string version of the value

func Status

func Status(s string) func(*ListOpts)

func Valid

func Valid(id string) bool

Valid returns true if a given id is a valid mongo id

Types

type DB

type DB struct {

	// MongoDB Support.
	Database *mongo.Database
}

DB is a collection of support for different DB technologies. Currently only MongoDB has been implemented. We want to be able to access the raw database support for the given DB so an interface does not work. Each database is too different.

func New

func New(url string, database string, timeout time.Duration) (*DB, error)

New returns a new DB value for use with MongoDB based on a registered master session.

func (*DB) Close

func (db *DB) Close() error

Close closes a DB value being used with MongoDB.

func (*DB) Copy

func (db *DB) Copy()

Copy returns a new DB value for use with MongoDB based on master session.

func (db *DB) Copy() *DB {
	ses := db.session.Copy()

func (*DB) Execute

func (db *DB) Execute(ctx context.Context, collName string, f func(*mongo.Collection) error) error

Execute is used to execute MongoDB commands.

func (*DB) ExecuteTimeout

func (db *DB) ExecuteTimeout(ctx context.Context, timeout time.Duration, collName string, f func(*mongo.Collection) error) error

ExecuteTimeout is used to execute MongoDB commands with a timeout.

func (*DB) StatusCheck

func (db *DB) StatusCheck(ctx context.Context) error

StatusCheck validates the DB status good.

type ListOpts

type ListOpts struct {
	Limit   int
	Offset  int
	Org     string
	Deleted bool
	Status  string
}

func DefaultOpts

func DefaultOpts() ListOpts

Jump to

Keyboard shortcuts

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