testdb

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Mar 17, 2019 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type TestDb

type TestDb struct {
	Session *mgo.Session
	*mgo.Database
	// contains filtered or unexported fields
}

TestDb create a connection to mongodb, and delete the database in reset. Also provide mongodb operation methods, so we do not need to deal with returned error. *mgo.Databae is nested in, so all Database method con be used directly from TestDb, such as:

db := testdb.New("blah_test")
db.C("tbl").Insert(...

Instead of:

db.Session.DB("").C("tbl").Insert(...

func New

func New(dbUrl string) *TestDb

Create a new TestDb instance.

func (*TestDb) Url

func (db *TestDb) Url() string

Return mongodb connection url

Jump to

Keyboard shortcuts

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