xorm

package
v0.0.0-...-2fc5dd3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 19, 2019 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DBCONFIG_FILE  = "./config/xorm.ini"
	DATABASE_DIR   = "database/"
	DEFAULTDB_NAME = "default"
)

default constant

Variables

View Source
var DB_ROOT string

当前项目根目录

Functions

func Callback

func Callback(fn func(*xorm.Session) error, session ...*xorm.Session) error

Callback uses the `default` database for non-transactional operations.

func CallbackByName

func CallbackByName(dbName string, fn func(*xorm.Session) error, session ...*xorm.Session) error

CallbackByName uses the specified database for non-transactional operations.

func DB

func DB(name ...string) (*xorm.Engine, bool)

DB is similar to MustDB, but safe.

func DBConfigPath

func DBConfigPath() string

获取项目路径

func List

func List() map[string]*xorm.Engine

List gets the list of database engines

func MustDB

func MustDB(name ...string) *xorm.Engine

MustDB gets the specified database engine, or the default DB if no name is specified.

func TransactCallback

func TransactCallback(fn func(*xorm.Session) error, session ...*xorm.Session) (err error)

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(*xorm.Session) error, session ...*xorm.Session) (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"`
	TableFix     string `ini:"table_fix" comment:"the table namespace is located in the prefix or suffix: prefix | suffix"`
	TableSpace   string `ini:"table_space" comment:"table namespace"`
	TableSnake   bool   `ini:"table_snake" comment:"the table name uses the snake style or remains unchanged"`
	ColumnFix    string `ini:"column_fix" comment:"column namespace is located in the prefix or suffix: prefix | suffix"`
	ColumnSpace  string `ini:"column_space" comment:"column namespace"`
	ColumnSnake  bool   `ini:"column_snake" comment:"the column name uses the snake style or remains unchanged"`
	DisableCache bool   `ini:"disable_cache"`
	ShowExecTime bool   `ini:"show_exec_time" comment:"print exec time"`
}

DBConfig is database connection config

func Config

func Config(name ...string) (DBConfig, bool)

Config is similar to MustConfig, but safe.

func MustConfig

func MustConfig(name ...string) DBConfig

MustConfig gets the configuration information for the specified database, or returns the default if no name is specified.

type DBService

type DBService struct {
	Default *xorm.Engine            // the default database engine
	List    map[string]*xorm.Engine // database engine list
}

DBService is a database engine object.

type Table

type Table interface {
	TableName() string
}

Table returns table name

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL