Documentation ¶
Index ¶
- type ErrorConverter
- type GormDbExt
- func (self *GormDbExt) IfRecordNotFound(foundValue interface{}, notFoundValue interface{}) interface{}
- func (self *GormDbExt) InTx(txCallback TxCallback)
- func (self *GormDbExt) IsRecordNotFound() bool
- func (self *GormDbExt) IterateRows(rowsCallback db.RowsCallback)
- func (self *GormDbExt) PanicIfError() *GormDbExt
- func (self *GormDbExt) Rows() *sql.Rows
- func (self *GormDbExt) ScanRows(rows *sql.Rows, result interface{})
- func (self *GormDbExt) SelectWithFoundRows(txCallback TxCallback, paging *commonModel.Paging)
- type TxCallback
- type TxCallbackFunc
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ErrorConverter ¶
Converter of error
var DefaultGormErrorConverter ErrorConverter = func(err error) error { if !utils.IsViable(err) { return nil } return db.NewDatabaseError(err) }
This function converts the error to default database error
See ToGormDbExt
func (ErrorConverter) PanicIfDbError ¶
func (self ErrorConverter) PanicIfDbError(gormDb *gorm.DB)
Raise panic if the error is not nil
func (ErrorConverter) PanicIfError ¶
func (self ErrorConverter) PanicIfError(err error)
Raise panic if the error is not nil
type GormDbExt ¶
type GormDbExt struct { // Error converter of Orm ConvertError ErrorConverter // contains filtered or unexported fields }
func ToDefaultGormDbExt ¶
Converts gormDb to GormDbExt with conversion of DbError
func (*GormDbExt) IfRecordNotFound ¶
func (self *GormDbExt) IfRecordNotFound(foundValue interface{}, notFoundValue interface{}) interface{}
Gets the foundValue if there is no error. Or gets notFoundValue if the error is gorm.ErrRecordNotFound
This function also calls PanicIfError(
func (*GormDbExt) InTx ¶
func (self *GormDbExt) InTx(txCallback TxCallback)
Executes gorm in transaction
func (*GormDbExt) IsRecordNotFound ¶
func (*GormDbExt) IterateRows ¶
func (self *GormDbExt) IterateRows( rowsCallback db.RowsCallback, )
Iterate rows(and close it) with callback
func (*GormDbExt) PanicIfError ¶
Raise panic if the Gorm has error
func (*GormDbExt) SelectWithFoundRows ¶
func (self *GormDbExt) SelectWithFoundRows(txCallback TxCallback, paging *commonModel.Paging)
Selects the query by callback and perform "SELECT FOUND_ROWS()" to gets the total number of matched rows
type TxCallback ¶
Callback function for transaction
Click to show internal directories.
Click to hide internal directories.