mgo

package
v0.0.0-...-f1d8006 Latest Latest
Warning

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

Go to latest
Published: Aug 6, 2013 License: MIT Imports: 2 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DbHelper

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

DbHelper is a convenience helper for systems that work with a single mongo DB. It creates a 'master' session, given the mgo url/db and init options and then uses its copies for db operations.

func Dial

func Dial(dialInfo *mgo.DialInfo, opts *DbHelperInitOptions) (d *DbHelper, err error)

Dial connects to the db using specified options and returns helper or error if dial fails.

func (*DbHelper) C

func (db *DbHelper) C(collectionName string) (*mgo.Collection, *mgo.Session)

C is a shortcut for getting a collection+session (master session copy) by name inside current database

func (*DbHelper) Cs

func (db *DbHelper) Cs(collectionName string, session *mgo.Session) *mgo.Collection

Cs is a shortcut for creating a collection using an existing session

func (*DbHelper) S

func (db *DbHelper) S() *mgo.Session

S is a shortcut for creating a session for current database

type DbHelperInitOptions

type DbHelperInitOptions struct {
	Safe *mgo.Safe // Safe mode set for DbHelper session.
}

DbHelperInitOptions contain initialization options for DbHelper constructor.

Jump to

Keyboard shortcuts

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