mgo

package
v0.0.0-...-2d91a95 Latest Latest
Warning

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

Go to latest
Published: Sep 7, 2017 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MaxLen int = 5000 // allocate the insert
)

Variables

View Source
var (
	MgoPool = pool.ClassicPool(
		config.MGO_CONN_CAP,
		config.MGO_CONN_CAP/5,
		func() (pool.Src, error) {

			return &MgoSrc{session.Clone()}, err
		},
		connGcSecond)
)

Functions

func Call

func Call(fn func(pool.Src) error) error

call the resource in the resource pool

func Close

func Close()

Destroy resource pool

func CollectionNames

func CollectionNames(dbname string) (names []string, err error)

Get the list of database collections

func DatabaseNames

func DatabaseNames() (names []string, err error)

Get all the data

func Error

func Error() error

func Len

func Len() int

returns the current number of resources

func Mgo

func Mgo(resultPtr interface{}, operate string, option map[string]interface{}) error

Create a unified method of checking and removing operations count operation resultPtr type is * int list operation The resultPtr type is * map [string] [] string find operation resultPtr type * map [string] interface {} insert operation resultPtr type is * [] string, allowed to nil (do not receive id list) The update operation resultPtr is nil remove operation resultPtr is nil

func Refresh

func Refresh()

Types

type Count

type Count struct {
	Database   string                 // database
	Collection string                 // collection
	Query      map[string]interface{} // Check for phrases
}

incoming database and collection name | return the total number of documents

func (*Count) Exec

func (count *Count) Exec(resultPtr interface{}) (err error)

type Find

type Find struct {
	Database   string                 // database
	Collection string                 // collection
	Query      map[string]interface{} // Check for phrases
	Sort       []string               // sort, usage such as Sort ("firstname", "-lastname"), preceded by firstname, followed by lastname
	Skip       int                    // skip the previous n documents
	Limit      int                    // return up to n documents
	Select     interface{}            // query only, return to the specified field, such as {"name": 1}

}

in the specified set of conditions for inquiries

func (*Find) Exec

func (find *Find) Exec(resultPtr interface{}) (err error)

type Insert

type Insert struct {
	Database   string                   // database
	Collection string                   // collection
	Docs       []map[string]interface{} // documentation
}

insert new data

func (*Insert) Exec

func (insert *Insert) Exec(resultPtr interface{}) (err error)

type List

type List struct {
	Dbs []string // list of database names
}

incoming database list | return database and its collection tree

func (*List) Exec

func (list *List) Exec(resultPtr interface{}) (err error)

type MgoSrc

type MgoSrc struct {
	*mgo.Session
}

func (*MgoSrc) Close

func (mgoSrc *MgoSrc) Close()

By the resource pool before the self-destruction method

func (*MgoSrc) Reset

func (*MgoSrc) Reset()

After using the reset method

func (*MgoSrc) Usable

func (mgoSrc *MgoSrc) Usable() bool

determine whether the resource is available

type Operator

type Operator interface {
	Exec(resultPtr interface{}) (err error)
}

add or delete operations

type Remove

type Remove struct {
	Database   string                 // database
	Collection string                 // collection
	Selector   map[string]interface{} // document selector
}

delete data

func (*Remove) Exec

func (remove *Remove) Exec(_ interface{}) error

type Update

type Update struct {
	Database   string                 // database
	Collection string                 // collection
	Selector   map[string]interface{} // document selector
	Change     map[string]interface{} // document update content
}

update the first matching data

func (*Update) Exec

func (update *Update) Exec(_ interface{}) error

type UpdateAll

type UpdateAll struct {
	Database   string                 // database
	Collection string                 // collection
	Selector   map[string]interface{} // document selector
	Change     map[string]interface{} // document update content
}

Update all matching data

func (*UpdateAll) Exec

func (updateAll *UpdateAll) Exec(resultPtr interface{}) (err error)

type Upsert

type Upsert struct {
	Database   string                 // database
	Collection string                 // collection
	Selector   map[string]interface{} // document selector
	Change     map[string]interface{} // document update content
}

update the first matching data, if no match is inserted

func (*Upsert) Exec

func (upsert *Upsert) Exec(resultPtr interface{}) (err error)

Jump to

Keyboard shortcuts

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