mgodb

package
v0.0.0-...-7ddd105 Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2020 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var MgoMode = struct {
	Eventual  int
	Monotonic int
	Strong    int
}{
	Eventual:  0,
	Monotonic: 1,
	Strong:    2,
}

MgoMode ...

Functions

func Dial

func Dial(host string, mode int, syncTimeoutInS int64) (session *mgo.Session, err error)

Dial establishes a new session to the cluster identified by the given seed server(s). The session will enable communication with all of the servers in the cluster, so the seed servers are used only to find out about the cluster topology.

func InitCollections

func InitCollections(ret interface{}, db *mgo.Database) (err error)

InitCollections initialize a set of collections

func Open

func Open(ret interface{}, cfg *Config) (session *mgo.Session, err error)

Open a mgon.Session

func SetMode

func SetMode(s *mgo.Session, mode int, refresh bool)

SetMode changes the consistency mode for the session.

Types

type Collection

type Collection struct {
	*mgo.Collection
}

Collection ...

func (Collection) CloseSession

func (c Collection) CloseSession() (err error)

CloseSession close session

func (Collection) CopySession

func (c Collection) CopySession() Collection

CopySession copy a session

func (Collection) EnsureIndexes

func (c Collection) EnsureIndexes(indexes ...string)

EnsureIndexes ensure indexes for a collection

eg. c.EnsureIndexes(

"uid :unique", "email :unique",
"serial_num", "uid,status,delete :sparse,background")

type Config

type Config struct {
	Host           string `json:"host"`
	DB             string `json:"db"`
	Mode           int    `json:"mode"`
	SyncTimeoutInS int64  `json:"timeout"`
}

Config ...

Jump to

Keyboard shortcuts

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