// DialMongoDB connect a mongo database with options
DialMongoDB connect a mongo database with options
// DialMongoDB connect a mongo database with options
func DialMongoDB(opt xlog.Options) (db *MongoDB, err error) {
	var di *mgo.DialInfo
	if di, err = mgo.ParseURL(opt.Mongo.URL); err != nil {
		return
	}
	if opt.Mongo.Tough {
		di.ReadTimeout = 0
	}
	var session *mgo.Session
	if session, err = mgo.DialWithInfo(di); err != nil {
		return
	}
	if opt.Mongo.Tough {
		session.SetCursorTimeout(0)
	}
	db = &MongoDB{
		DB:               session.DB(opt.Mongo.DB),
		CollectionPrefix: opt.Mongo.Collection,
	}
	return
}
func DialMongoDB ( opt xlog . Options ) ( db * MongoDB , err error ) { var di * mgo . DialInfo if di , err = mgo . ParseURL ( opt . Mongo . URL ) ; err != nil { return } if opt . Mongo . Tough { di . ReadTimeout = 0 } var session * mgo . Session if session , err = mgo . DialWithInfo ( di ) ; err != nil { return } if opt . Mongo . Tough { session . SetCursorTimeout ( 0 ) } db = & MongoDB { DB : session . DB ( opt . Mongo . DB ) , CollectionPrefix : opt . Mongo . Collection , } return }
DialMongoDB connect a mongo database with options
DialMongoDB connect a mongo database with options
// parse url // set read timeout to 0 for tough mode // create session // wrap