db

package
v0.3.5 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2018 License: Apache-2.0 Imports: 5 Imported by: 12

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Hosts []string
	// AuthSource Specify the database name associated with the user’s credentials.
	// authSource defaults to the database specified in the connection string.
	AuthSource string
	UserName   string
	Password   string
	Database   string
	Timeout    time.Duration // second
}

type Mdb

type Mdb struct {
	*Config
	*mgo.Session
}

func NewMdb

func NewMdb(c *Config) (*Mdb, error)

func (*Mdb) FindId

func (self *Mdb) FindId(collection string, id interface{}, result interface{}) error

func (*Mdb) FindOne

func (self *Mdb) FindOne(collection string, query interface{}, result interface{}) error

func (*Mdb) Insert

func (self *Mdb) Insert(collection string, data ...interface{}) error

func (*Mdb) RemoveId added in v0.3.1

func (self *Mdb) RemoveId(collection string, id interface{}) error

func (*Mdb) Upsert

func (self *Mdb) Upsert(collection string, selector interface{}, change interface{}) error

func (*Mdb) WithC

func (m *Mdb) WithC(collection string, job func(*mgo.Collection) error) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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