persistences

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2019 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var LintGonicLowerCaseMapper = GonicLowerCaseMapper{
	// contains filtered or unexported fields
}

LintGonicLowerCaseMapper lists of commonly used acronyms

View Source
var LintGonicLowerCasePluralizeMapper = GonicLowerCasePluralizeMapper{
	// contains filtered or unexported fields
}

LintGonicLowerCasePluralizeMapper lists of commonly used acronyms

View Source
var LintGonicUpperCaseMapper = GonicUpperCaseMapper{
	// contains filtered or unexported fields
}

LintGonicUpperCaseMapper lists of commonly used acronyms

View Source
var LintGonicUpperCasePluralizeMapper = GonicUpperCasePluralizeMapper{
	// contains filtered or unexported fields
}

LintGonicUpperCasePluralizeMapper lists of commonly used acronyms

Functions

func CreateMigrationTableIfNotExists

func CreateMigrationTableIfNotExists(db *xorm.Engine, options *migrate.Options) error

CreateMigrationTableIfNotExists は migration テーブルを作成する. xorm.migrate.createMigrationTableIfNotExists は ROW_FORMAT を指定できないので使わない.

func GetEngine

func GetEngine() *xorm.Engine

GetEngine は xorm engine の取得を行う.

func InitEngine

func InitEngine(driver, dataSource string, showSQL bool, migrationPath string) error

InitEngine は xorm engine の初期化を行う.

func NewSession

func NewSession() *xorm.Session

NewSession は xorm session を開始する.

func ReadMigrationDir

func ReadMigrationDir(dir string) ([]*migrate.Migration, error)

ReadMigrationDir は dir から *.sql ファイルを読んで migration スライスを返す.

func ThrowDBError

func ThrowDBError(err error)

ThrowDBError は HandleDBError にラップした error を panic に渡す.

Types

type CommonDBA

type CommonDBA struct {
	// contains filtered or unexported fields
}

CommonDBA is commonDBA of User.

func GetCommonDBA

func GetCommonDBA() *CommonDBA

GetCommonDBA return a common commonDBA instance.

func (*CommonDBA) DeleteByID

func (commonDBA *CommonDBA) DeleteByID(session *xorm.Session, id int, record interface{}) int64

DeleteByID 指定されたフィールドを削除する.

func (*CommonDBA) InsertMany

func (commonDBA *CommonDBA) InsertMany(session *xorm.Session, records interface{}) int64

InsertMany Entity

func (*CommonDBA) InsertOne

func (commonDBA *CommonDBA) InsertOne(session *xorm.Session, record interface{}) int64

InsertOne Entity

func (*CommonDBA) Run

func (commonDBA *CommonDBA) Run(fn func(session *xorm.Session) error) (result error)

Run does statements in db session without transaction.

func (*CommonDBA) RunInTransaction

func (commonDBA *CommonDBA) RunInTransaction(fn func(session *xorm.Session) error) (result error)

RunInTransaction does statements in db transaction.

func (*CommonDBA) UpdateByID

func (commonDBA *CommonDBA) UpdateByID(session *xorm.Session, id int, record interface{}) int64

UpdateByID 指定されたフィールドを更新する.

type GonicLowerCaseMapper

type GonicLowerCaseMapper struct {
	// contains filtered or unexported fields
}

GonicLowerCaseMapper E.g. ID -> ID, USER -> User and to table names: UserID -> USER_ID, MyUID -> MY_UID

func (GonicLowerCaseMapper) Obj2Table

func (mapper GonicLowerCaseMapper) Obj2Table(name string) string

Obj2Table provides Obj field -> Table column mapping.

func (GonicLowerCaseMapper) Table2Obj

func (mapper GonicLowerCaseMapper) Table2Obj(name string) string

Table2Obj Provides Table column -> Obj field mapping.

type GonicLowerCasePluralizeMapper

type GonicLowerCasePluralizeMapper struct {
	// contains filtered or unexported fields
}

GonicLowerCasePluralizeMapper E.g. USERS -> user, COMPANIES -> Company and to table names: User -> users, CompanyAccount -> company_accounts

func (GonicLowerCasePluralizeMapper) Obj2Table

func (mapper GonicLowerCasePluralizeMapper) Obj2Table(name string) string

Obj2Table provides Obj field -> Table column mapping.

func (GonicLowerCasePluralizeMapper) Table2Obj

func (mapper GonicLowerCasePluralizeMapper) Table2Obj(name string) string

Table2Obj Provides Table column -> Obj field mapping.

type GonicUpperCaseMapper

type GonicUpperCaseMapper struct {
	// contains filtered or unexported fields
}

GonicUpperCaseMapper E.g. ID -> ID, USER -> User and to table names: UserID -> USER_ID, MyUID -> MY_UID

func (GonicUpperCaseMapper) Obj2Table

func (mapper GonicUpperCaseMapper) Obj2Table(name string) string

Obj2Table provides Obj field -> Table column mapping.

func (GonicUpperCaseMapper) Table2Obj

func (mapper GonicUpperCaseMapper) Table2Obj(name string) string

Table2Obj Provides Table column -> Obj field mapping.

type GonicUpperCasePluralizeMapper

type GonicUpperCasePluralizeMapper struct {
	// contains filtered or unexported fields
}

GonicUpperCasePluralizeMapper E.g. USERS -> User, COMPANIES -> Company and to table names: User -> USERS, CompanyAccount -> COMPANY_ACCOUNTS

func (GonicUpperCasePluralizeMapper) Obj2Table

func (mapper GonicUpperCasePluralizeMapper) Obj2Table(name string) string

Obj2Table provides Obj field -> Table column mapping.

func (GonicUpperCasePluralizeMapper) Table2Obj

func (mapper GonicUpperCasePluralizeMapper) Table2Obj(name string) string

Table2Obj Provides Table column -> Obj field mapping.

type HandledDBError

type HandledDBError struct {
	DBError error
}

HandledDBError represents a error reason by code and reason string.

func (*HandledDBError) Error

func (e *HandledDBError) Error() string

Error returns error reason.

Jump to

Keyboard shortcuts

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