diff --git a/session.go b/session.go index 1bb276b..8b42aea 100644 --- a/session.go +++ b/session.go @@ -33,16 +33,21 @@ func NewSession(dial string) (*Session, error) { type Database struct { database *mgo.Database + session *Session } func (s *Session) DB(name string) *Database { - return &Database{database: s.session.DB(name)} + return &Database{database: s.session.DB(name), session: s} } type Collection struct { collection *mgo.Collection } +func (db *Database) Session() *Session { + return db.session +} + func (db *Database) C(name string) *Collection { return &Collection{collection: db.database.C(name)} }