db.Session()
This commit is contained in:
parent
7dd238342c
commit
98801edbc0
@ -33,16 +33,21 @@ func NewSession(dial string) (*Session, error) {
|
|||||||
|
|
||||||
type Database struct {
|
type Database struct {
|
||||||
database *mgo.Database
|
database *mgo.Database
|
||||||
|
session *Session
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Session) DB(name string) *Database {
|
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 {
|
type Collection struct {
|
||||||
collection *mgo.Collection
|
collection *mgo.Collection
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (db *Database) Session() *Session {
|
||||||
|
return db.session
|
||||||
|
}
|
||||||
|
|
||||||
func (db *Database) C(name string) *Collection {
|
func (db *Database) C(name string) *Collection {
|
||||||
return &Collection{collection: db.database.C(name)}
|
return &Collection{collection: db.database.C(name)}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user