mongo

package
v1.32.2 Latest Latest
Warning

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

Go to latest
Published: Feb 11, 2020 License: BSD-2-Clause Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ModifyQuery added in v1.31.0

func ModifyQuery(query bson.M, queryModifiers ...QueryModifier) bson.M

func NotDeleted added in v1.31.0

func NotDeleted(query bson.M) bson.M

func SplitAddresses

func SplitAddresses(addresses string) []string

Types

type Config

type Config struct {
	Scheme           string        `json:"scheme"`
	Addresses        []string      `json:"addresses"`
	TLS              bool          `json:"tls"`
	Database         string        `json:"database"`
	CollectionPrefix string        `json:"collectionPrefix"`
	Username         *string       `json:"-"`
	Password         *string       `json:"-"`
	Timeout          time.Duration `json:"timeout"`
	OptParams        *string       `json:"optParams"`
}

Config describe parameters need to make a connection to a Mongo database

func NewConfig

func NewConfig() *Config

NewConfig creates and returns an incomplete Config object

func (*Config) AsConnectionString added in v1.32.1

func (c *Config) AsConnectionString() string

AsConnectionString constructs a MongoDB connection string from a Config

func (*Config) Load

func (c *Config) Load(configReporter config.Reporter) error

Load a Config with the values provided via a config.Reporter

func (*Config) Validate

func (c *Config) Validate() error

Validate that all parameters are syntactically valid, that all required parameters are present, and the the URL constructed from those parameters is parseable by the Mongo driver

type QueryModifier added in v1.31.0

type QueryModifier func(query bson.M) bson.M

type Session

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

func (*Session) C

func (s *Session) C() *mgo.Collection

func (*Session) Close

func (s *Session) Close() error

func (*Session) ConstructUpdate

func (s *Session) ConstructUpdate(set bson.M, unset bson.M, operators ...map[string]bson.M) bson.M

func (*Session) EnsureAllIndexes

func (s *Session) EnsureAllIndexes(indexes []mgo.Index) error

func (*Session) IsClosed

func (s *Session) IsClosed() bool

type Status

type Status struct {
	State       string
	BuildInfo   *mgo.BuildInfo
	LiveServers []string
	Mode        mgo.Mode
	Safe        *mgo.Safe
	Ping        string
}

type Store

type Store struct {
	Config  *Config
	Session *mgo.Session
}

Store represents a live session to a Mongo database

func NewStore

func NewStore(config *Config, logger log.Logger) (*Store, error)

NewStore constructs a Store from a Config, using the given logger

func (*Store) Close

func (s *Store) Close() error

Close the session to the Mongo database

func (*Store) IsClosed

func (s *Store) IsClosed() bool

IsClosed returns true if the session is closed

func (*Store) NewSession

func (s *Store) NewSession(collection string) *Session

func (*Store) Status

func (s *Store) Status() interface{}

Status returns the current state of the sessions

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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