orm

package
v0.0.0-...-9f39f39 Latest Latest
Warning

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

Go to latest
Published: Mar 23, 2023 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Create

func Create(db *gorm.DB, in interface{}) xerror.IError

func Delete

func Delete(db *gorm.DB, table interface{}, options ...Option) xerror.IError

func DoOption

func DoOption(db *gorm.DB, opts ...Option) *gorm.DB

func GetDB

func GetDB() *gorm.DB

func GetDBWithCtx

func GetDBWithCtx(ctx context.Context) *gorm.DB

func GetFirstRecord

func GetFirstRecord(db *gorm.DB, in interface{}, options ...Option) xerror.IError

func GetListRecord

func GetListRecord(db *gorm.DB, in interface{}, options ...Option) xerror.IError

func Initialize

func Initialize() (err error)

func NewDbError

func NewDbError(err error) xerror.IError

func NewOrm

func NewOrm(dsn string) (*gorm.DB, error)

func ParseOrmDsn

func ParseOrmDsn(dsn string) (gorm.Dialector, error)

func Updates

func Updates(db *gorm.DB, in interface{}, options ...Option) xerror.IError

Types

type BaseModel

type BaseModel struct {
	Id        int            `json:"id" gorm:"primary_key"`
	Uuid      string         `json:"uuid" gorm:"index"`
	CreatedAt time.Time      `json:"created_at"`
	UpdatedAt time.Time      `json:"updated_at"`
	Deleted   gorm.DeletedAt `json:"deleted" gorm:"index"`
}

type BasePageReq

type BasePageReq struct {
	Page int `json:"page"`
	Size int `json:"size"`
}

type BasePageResp

type BasePageResp struct {
	Count int64       `json:"count"`
	Data  interface{} `json:"data"`
}

func GetPageListRecord

func GetPageListRecord(db *gorm.DB, page, size int, in interface{}, options ...Option) (*BasePageResp, xerror.IError)

func GetPageListRecord2

func GetPageListRecord2(db *gorm.DB, page *BasePageReq, in interface{}, options ...Option) (*BasePageResp, xerror.IError)

type DbError

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

func (*DbError) Detail

func (e *DbError) Detail() string

func (*DbError) Error

func (e *DbError) Error() string

func (*DbError) Info

func (e *DbError) Info() string

type Option

type Option func(*gorm.DB) *gorm.DB

func Option_Model

func Option_Model(m schema.Tabler) Option

func Option_Table

func Option_Table(tableName string) Option

func SearchOption_UUID

func SearchOption_UUID(uuid string) Option

type SimpleBaseModel

type SimpleBaseModel struct {
	Id        int            `json:"id" gorm:"primary_key"`
	CreatedAt time.Time      `json:"created_at"`
	UpdatedAt time.Time      `json:"updated_at"`
	Deleted   gorm.DeletedAt `json:"deleted" gorm:"index"`
}

Jump to

Keyboard shortcuts

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