Documentation
¶
Index ¶
- Constants
- Variables
- func Callback(fn func(*gorm.DB) error, session ...*gorm.DB) error
- func CallbackByName(dbName string, fn func(*gorm.DB) error, session ...*gorm.DB) error
- func DB(name ...string) (*gorm.DB, bool)
- func List() map[string]*gorm.DB
- func MustDB(name ...string) *gorm.DB
- func TransactCallback(fn func(*gorm.DB) error, session ...*gorm.DB) (err error)
- func TransactCallbackByName(dbName string, fn func(*gorm.DB) error, session ...*gorm.DB) (err error)
- type DBConfig
- type DBService
Constants ¶
View Source
const ( DATABASE_DIR = "database/" DEFAULTDB_NAME = "default" )
default constant
Variables ¶
Functions ¶
func Callback ¶
Callback uses the `default` database for non-transactional operations.
func CallbackByName ¶
CallbackByName uses the specified database for non-transactional operations.
func MustDB ¶
MustDB gets the specified database engine, or the default DB if no name is specified.
func TransactCallback ¶
TransactCallback uses the default database for transactional operations.
Types ¶
type DBConfig ¶
type DBConfig struct {
Name string `ini:"-"`
Enable bool `ini:"enable" comment:"Enable the config section"`
Driver string `ini:"driver" comment:"mssql | odbc(mssql) | mysql | mymysql | postgres | sqlite3 | oci8 | goracle"`
Connstring string `ini:"connstring" comment:"Connect String"`
MaxOpenConns int `ini:"max_open_conns"`
MaxIdleConns int `ini:"max_idle_conns"`
ShowSql bool `ini:"show_sql" comment:"print sql"`
}
DBConfig is database connection config
func Config ¶
Config is similar to MustConfig, but safe.
Source Files
¶
- config.go
- helper.go
- service.go
Click to show internal directories.
Click to hide internal directories.