utilOrm

package
v0.0.0-...-fe5de01 Latest Latest
Warning

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

Go to latest
Published: Dec 17, 2024 License: MIT Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ErrorIsOrmNotFound

func ErrorIsOrmNotFound(err error) bool

Types

type GormQuery

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

func (*GormQuery) Count

func (q *GormQuery) Count() (count int64, err error)

func (*GormQuery) Create

func (q *GormQuery) Create(value interface{}) (err error)

func (*GormQuery) CreateInBatches

func (q *GormQuery) CreateInBatches(value interface{}, batchSize int) (err error)

func (*GormQuery) Delete

func (q *GormQuery) Delete(model interface{}, conds ...interface{}) (err error)

func (*GormQuery) Distinct

func (q *GormQuery) Distinct(args ...interface{}) *GormQuery

func (*GormQuery) Find

func (q *GormQuery) Find(models interface{}, conds ...interface{}) (err error)

func (*GormQuery) First

func (q *GormQuery) First(model interface{}, conds ...interface{}) (err error)

func (*GormQuery) FirstOrCreate

func (q *GormQuery) FirstOrCreate(model interface{}, conds ...interface{}) (err error)

func (*GormQuery) Group

func (q *GormQuery) Group(name string) *GormQuery

func (*GormQuery) Having

func (q *GormQuery) Having(query string, args ...interface{}) *GormQuery

func (*GormQuery) IncludeDeleted

func (q *GormQuery) IncludeDeleted() *GormQuery

func (*GormQuery) InnerJoins

func (q *GormQuery) InnerJoins(query string, args ...interface{}) *GormQuery

func (*GormQuery) Joins

func (q *GormQuery) Joins(query string, args ...interface{}) *GormQuery

func (*GormQuery) Limit

func (q *GormQuery) Limit(limit int) *GormQuery

func (*GormQuery) Not

func (q *GormQuery) Not(query interface{}, args ...interface{}) *GormQuery

func (*GormQuery) Offset

func (q *GormQuery) Offset(offset int) *GormQuery

func (*GormQuery) Or

func (q *GormQuery) Or(query interface{}, args ...interface{}) *GormQuery

func (*GormQuery) Order

func (q *GormQuery) Order(value interface{}) *GormQuery

func (*GormQuery) Pluck

func (q *GormQuery) Pluck(column string, model interface{}) (err error)

func (*GormQuery) Save

func (q *GormQuery) Save(model interface{}) (err error)

func (*GormQuery) Scan

func (q *GormQuery) Scan(model interface{}) (err error)

func (*GormQuery) Select

func (q *GormQuery) Select(query interface{}, args ...interface{}) *GormQuery

func (*GormQuery) SoftDelete

func (q *GormQuery) SoftDelete(model interface{}, conds ...interface{}) (err error)

func (*GormQuery) Update

func (q *GormQuery) Update(data interface{}) (err error)

func (*GormQuery) Where

func (q *GormQuery) Where(query interface{}, args ...interface{}) *GormQuery

func (*GormQuery) WithPager

func (q *GormQuery) WithPager(p *utilHttp.Paginator) *GormQuery

func (*GormQuery) WithRelate

func (q *GormQuery) WithRelate(query string, args ...interface{}) *GormQuery

type OrmModel

type OrmModel interface {
	GetPrimaryKey() string
	GetPrimaryKeyFiledName() string
	GetPrimaryKeyFiledNameSnake() string
}

type OrmModelGormBase

type OrmModelGormBase struct {
	Id        string         `gorm:"primaryKey;size:36" json:"id,omitempty" form:"id"`
	CreatedAt time.Time      `gorm:"autoCreateTime;<-:create;index:index_created_at" json:"created_at" form:"-"`
	UpdatedAt time.Time      `gorm:"autoUpdateTime:nano;index:index_updated_at" json:"updated_at" form:"-"`
	DeletedAt gorm.DeletedAt `json:"deleted_at" form:"-"`
}

func (*OrmModelGormBase) BeforeCreate

func (om *OrmModelGormBase) BeforeCreate(tx *gorm.DB) (err error)

func (*OrmModelGormBase) GetPrimaryKey

func (om *OrmModelGormBase) GetPrimaryKey() string

func (*OrmModelGormBase) GetPrimaryKeyFiledName

func (om *OrmModelGormBase) GetPrimaryKeyFiledName() string

func (*OrmModelGormBase) GetPrimaryKeyFiledNameSnake

func (om *OrmModelGormBase) GetPrimaryKeyFiledNameSnake() string

type OrmMysqlJsonSliceString

type OrmMysqlJsonSliceString []string

func (*OrmMysqlJsonSliceString) Scan

func (j *OrmMysqlJsonSliceString) Scan(value interface{}) error

实现 sql.Scanner 接口,Scan 将 value 扫描至 Jsonb

func (*OrmMysqlJsonSliceString) Value

func (j *OrmMysqlJsonSliceString) Value() (driver.Value, error)

实现 driver.Valuer 接口,Value 返回 json value

type UtilGorm

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

func NewUtilGormClickHouse

func NewUtilGormClickHouse(host string, port int, user string, password string, dbName string, tablePrefix string, timeout time.Duration, useSsl ...bool) (utilOrm *UtilGorm, err error)

func NewUtilGormMysql

func NewUtilGormMysql(host string, port int, user string, password string, dbName string, tablePrefix string, timeout time.Duration) (utilOrm *UtilGorm, err error)

func NewUtilGormSqlite

func NewUtilGormSqlite(dsn string, tablePrefix string) (utilOrm *UtilGorm, err error)

func (*UtilGorm) AutoMigrate

func (ug *UtilGorm) AutoMigrate(dst ...interface{}) (err error)

func (*UtilGorm) Begin

func (ug *UtilGorm) Begin(opts ...*sql.TxOptions) (err error)

func (*UtilGorm) Clauses

func (ug *UtilGorm) Clauses(conds ...clause.Expression) *UtilGorm

func (*UtilGorm) Clone

func (ug *UtilGorm) Clone() *UtilGorm

func (*UtilGorm) Commit

func (ug *UtilGorm) Commit() (err error)

func (*UtilGorm) Debug

func (ug *UtilGorm) Debug(debug bool) *UtilGorm

func (*UtilGorm) IncludeDeleted

func (ug *UtilGorm) IncludeDeleted() *UtilGorm

func (*UtilGorm) Migrator

func (ug *UtilGorm) Migrator() gorm.Migrator

func (*UtilGorm) ModelDelete

func (ug *UtilGorm) ModelDelete(model interface{}) error

func (*UtilGorm) ModelQuery

func (ug *UtilGorm) ModelQuery(model interface{}, orderBy *[]string) *GormQuery

func (*UtilGorm) ModelRead

func (ug *UtilGorm) ModelRead(model interface{}) error

func (*UtilGorm) ModelRelatedAppend

func (ug *UtilGorm) ModelRelatedAppend(model interface{}, related string, values ...interface{}) (err error)

func (*UtilGorm) ModelRelatedClear

func (ug *UtilGorm) ModelRelatedClear(model interface{}, related string) (err error)

func (*UtilGorm) ModelRelatedDelete

func (ug *UtilGorm) ModelRelatedDelete(model interface{}, related string, values ...interface{}) (err error)

func (*UtilGorm) ModelRelatedLoad

func (ug *UtilGorm) ModelRelatedLoad(model interface{}, related string, conds ...interface{}) (err error)

func (*UtilGorm) ModelRelatedReplace

func (ug *UtilGorm) ModelRelatedReplace(model interface{}, related string, values ...interface{}) (err error)

func (*UtilGorm) ModelSave

func (ug *UtilGorm) ModelSave(model interface{}) error

func (*UtilGorm) ModelTableName

func (ug *UtilGorm) ModelTableName(model interface{}) (name string)

func (*UtilGorm) Original

func (ug *UtilGorm) Original() *gorm.DB

func (*UtilGorm) Raw

func (ug *UtilGorm) Raw(sql string, values ...interface{}) (err error)

func (*UtilGorm) Rollback

func (ug *UtilGorm) Rollback() (err error)

func (*UtilGorm) RollbackTo

func (ug *UtilGorm) RollbackTo(name string) (err error)

func (*UtilGorm) SavePoint

func (ug *UtilGorm) SavePoint(name string) (err error)

func (*UtilGorm) Scopes

func (ug *UtilGorm) Scopes(funcs ...func(*gorm.DB) *gorm.DB) *UtilGorm

func (*UtilGorm) Select

func (ug *UtilGorm) Select(query interface{}, args ...interface{}) *UtilGorm

func (*UtilGorm) SerLoggerWriter

func (ug *UtilGorm) SerLoggerWriter(writer io.Writer) *UtilGorm

func (*UtilGorm) Session

func (ug *UtilGorm) Session(config *gorm.Session) *UtilGorm

func (*UtilGorm) Set

func (ug *UtilGorm) Set(key string, value interface{}) *UtilGorm

func (*UtilGorm) TableName

func (ug *UtilGorm) TableName(table string) (name string)

func (*UtilGorm) TableQuery

func (ug *UtilGorm) TableQuery(tableName string, orderBy *[]string, args ...interface{}) *GormQuery

func (*UtilGorm) Where

func (ug *UtilGorm) Where(query interface{}, args ...interface{}) *UtilGorm

func (*UtilGorm) WithRelate

func (ug *UtilGorm) WithRelate(query string, args ...interface{}) *UtilGorm

Jump to

Keyboard shortcuts

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