From 98801edbc058a131e8365f97c20909fe2ee1dd7e Mon Sep 17 00:00:00 2001 From: Sebastian Frank Date: Wed, 9 Feb 2022 18:55:58 +0100 Subject: [PATCH] db.Session() --- session.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) 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)} }