Documentation ¶
Index ¶
- Constants
- 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" DBCONFIG_FILE = "./config/gorm.ini" )
default constant
Variables ¶
This section is empty.
Functions ¶
func CallbackByName ¶
CallbackByName uses the specified database for non-transactional operations.
func TransactCallback ¶
TransactCallback uses the default database for transactional operations. note: if an error is returned, the rollback method should be invoked outside the function.
func TransactCallbackByName ¶
func TransactCallbackByName(dbName string, fn func(*gorm.DB) error, session ...*gorm.DB) (err error)
TransactCallbackByName uses the `specified` database for transactional operations. note: if an error is returned, the rollback method should be invoked outside the function.
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 MustConfig ¶
MustConfig gets the configuration information for the specified database, or returns the default if no name is specified.
Click to show internal directories.
Click to hide internal directories.