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 ¶
View Source
var ( // DBCONFIG_FILE config file path DBCONFIG_FILE = faygo.ConfigDir() + "gorm.ini" )
Functions ¶
func CallbackByName ¶
CallbackByName uses the specified database for non-transactional operations.
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 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.