mongo

package
v5.9.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2018 License: GPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DEFAULT_QUERY_TIMEOUT = 10 * time.Second
)

Variables

This section is empty.

Functions

func NewMongoLogger

func NewMongoLogger(logger golog.ILogger) *mongoLogger

Types

type Client

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

func NewClient

func NewClient(config *Config, logger golog.ILogger) *Client

func (*Client) BuildQuery

func (this *Client) BuildQuery(query *Query) *mgo.Query

func (*Client) Collection

func (this *Client) Collection(col string) *mgo.Collection

func (*Client) Connect

func (this *Client) Connect() error

func (*Client) Connected

func (this *Client) Connected() bool

func (*Client) Count

func (this *Client) Count() (n int, err error)

func (*Client) DB

func (this *Client) DB(name string) *mgo.Database

func (*Client) Find

func (this *Client) Find(query interface{}) *mgo.Query

func (*Client) FindId

func (this *Client) FindId(id interface{}) *mgo.Query

func (*Client) Free

func (this *Client) Free()

func (*Client) Indexes

func (this *Client) Indexes() (indexes []mgo.Index, err error)

func (*Client) Insert

func (this *Client) Insert(docs ...interface{}) error

func (*Client) Query

func (this *Client) Query(query *Query) (result []bson.M, err error)

func (*Client) QueryCount

func (this *Client) QueryCount(query *Query) (n int, err error)

func (*Client) QueryId

func (this *Client) QueryId(id interface{}) (result bson.M, err error)

func (*Client) QueryOne

func (this *Client) QueryOne(query *Query) (result bson.M, err error)

func (*Client) Remove

func (this *Client) Remove(selector interface{}) error

func (*Client) RemoveAll

func (this *Client) RemoveAll(selector interface{}) error

func (*Client) RemoveId

func (this *Client) RemoveId(id interface{}) error

func (*Client) SetCmdLogFmtFunc

func (this *Client) SetCmdLogFmtFunc(clff CmdLogFmtFunc) *Client

func (*Client) SetDebug

func (this *Client) SetDebug(debug bool)

func (*Client) SetLogger

func (this *Client) SetLogger(logger golog.ILogger) *Client

func (*Client) Update

func (this *Client) Update(selector, updater interface{}) error

func (*Client) UpdateAll

func (this *Client) UpdateAll(selector, updater interface{}) error

func (*Client) UpdateId

func (this *Client) UpdateId(id interface{}, updater interface{}) error

func (*Client) Upsert

func (this *Client) Upsert(selector, updater interface{}) error

type CmdLogFmtFunc

type CmdLogFmtFunc func(cmd string, args ...interface{}) []byte

type Config

type Config struct {
	LogLevel int

	Host   string
	Port   string
	User   string
	Pass   string
	DBName string

	QueryTimeout time.Duration
}

func NewConfig

func NewConfig(host, port, user, pass, dbname string) *Config

type PConfig

type PConfig struct {
	pool.Config

	NewClientFunc func() (*Client, error)
}

type Pool

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

func NewPool

func NewPool(config *PConfig) *Pool

func (*Pool) Get

func (this *Pool) Get() (*Client, error)

func (*Pool) Put

func (this *Pool) Put(client *Client) error

type Query

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

func NewQuery

func NewQuery() *Query

func (*Query) Limit

func (this *Query) Limit(n int) *Query

func (*Query) Query

func (this *Query) Query(query interface{}) *Query

func (*Query) Select

func (this *Query) Select(selector interface{}) *Query

func (*Query) SetMaxTime

func (this *Query) SetMaxTime(maxTime time.Duration) *Query

func (*Query) Skip

func (this *Query) Skip(n int) *Query

func (*Query) Sort

func (this *Query) Sort(fields ...string) *Query

Jump to

Keyboard shortcuts

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