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 ( DBCONFIG_FILE = faygo.CONFIG_DIR + "gorm.ini" DATABASE_DIR = "database/" DEFAULTDB_NAME = "default" )
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"` Driver string `ini:"driver"` // Driver:mssql | odbc(mssql) | mysql | mymysql | postgres | sqlite3 | oci8 | goracle Connstring string `ini:"connstring"` MaxOpenConns int `ini:"max_open_conns"` MaxIdleConns int `ini:"max_idle_conns"` ShowSql bool `ini:"show_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.