DB provides Close function
This commit is contained in:
parent
4a50b36f63
commit
da89fa99ba
9
gorm.go
9
gorm.go
@ -217,6 +217,15 @@ func Open(dialector Dialector, opts ...Option) (db *DB, err error) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Close close current db connection
|
||||||
|
func (db *DB) Close() error {
|
||||||
|
sqlDB, err := db.DB()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return sqlDB.Close()
|
||||||
|
}
|
||||||
|
|
||||||
// Session create new db session
|
// Session create new db session
|
||||||
func (db *DB) Session(config *Session) *DB {
|
func (db *DB) Session(config *Session) *DB {
|
||||||
var (
|
var (
|
||||||
|
Loading…
x
Reference in New Issue
Block a user