Documentation ¶
Index ¶
- type DbFacade
- func (facade *DbFacade) GetDbConfig() *commonDb.DbConfig
- func (facade *DbFacade) NewDbCtrl() *commonDb.DbController
- func (facade *DbFacade) NewSqlxDbCtrl() *commonSqlx.DbController
- func (facade *DbFacade) Open(dbConfig *commonDb.DbConfig) (err error)
- func (facade *DbFacade) Release()
- func (facade *DbFacade) SetReleaseCallback(callback func())
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DbFacade ¶
type DbFacade struct { SqlDb *sql.DB SqlDbCtrl *commonDb.DbController GormDb *gorm.DB SqlxDb *sqlx.DB SqlxDbCtrl *commonSqlx.DbController // contains filtered or unexported fields }
Gives facade interface supporting multiple object of db
This facade supports:
gorm - github.com/jinzhu/gorm sqlx - github.com/fwtpe/owl-backend/common/db/sqlx database/sql.DB dbCtrl
Release resources ¶
In order to release resources in solid way, this facade provides "SetReleaseCallback(func())" to register callback function which gets called before this object releases the connections of database.
func (*DbFacade) GetDbConfig ¶
Gets the configuration of database.
Warning: the information of password is revealed
func (*DbFacade) NewDbCtrl ¶
func (facade *DbFacade) NewDbCtrl() *commonDb.DbController
Generates a new controller of sql.DB
func (*DbFacade) NewSqlxDbCtrl ¶
func (facade *DbFacade) NewSqlxDbCtrl() *commonSqlx.DbController
Generates a new controller of sqlx.DB
func (*DbFacade) Release ¶
func (facade *DbFacade) Release()
Close the database, release the resources
func (*DbFacade) SetReleaseCallback ¶
func (facade *DbFacade) SetReleaseCallback(callback func())
Sets the callback used before releasing connections
Click to show internal directories.
Click to hide internal directories.