db.Session()

This commit is contained in:
Sebastian Frank 2022-02-09 18:55:58 +01:00
parent 7dd238342c
commit 98801edbc0
Signed by: apairon
GPG Key ID: A0E05A8199CE3F57

View File

@ -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)}
}