Documentation ¶
Index ¶
- type BaseRepo
- func (r *BaseRepo[T]) CountAll() (int64, error)
- func (r *BaseRepo[T]) DeleteBy(condition map[string]interface{}, hardDelete bool) error
- func (r *BaseRepo[T]) DeleteById(id uint64) error
- func (r *BaseRepo[T]) Exec(sql string, values ...interface{}) (*gorm.DB, error)
- func (r *BaseRepo[T]) FindBy(condition map[string]interface{}) (*T, error)
- func (r *BaseRepo[T]) FindByID(id uint64) (*T, error)
- func (r *BaseRepo[T]) GetByPage(page int, pageSize int) ([]*T, error)
- func (r *BaseRepo[T]) Insert(model *T) error
- func (r *BaseRepo[T]) InsertOrIgnore(model *T, condition map[string]interface{}) (int64, error)
- func (r *BaseRepo[T]) InsertOrUpdate(insertItem *T, condition map[string]interface{}, updateValues *T) error
- func (r *BaseRepo[T]) SelectBy(condition map[string]interface{}, results *[]*T, opts ...SelOpt) error
- func (r *BaseRepo[T]) UpdateBy(condition map[string]interface{}, updateValues *T) (int64, error)
- func (r *BaseRepo[T]) UpdateById(id uint64, updateValues *T) error
- func (r *BaseRepo[T]) Upsert(model *T, condition map[string]interface{}) error
- func (r *BaseRepo[T]) UpsertByID(model *T, updateFields []string) error
- type IBaseRepo
- type SelOpt
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BaseRepo ¶
func (*BaseRepo[T]) DeleteById ¶
DeleteById 按照ID删除一条
func (*BaseRepo[T]) InsertOrIgnore ¶
InsertOrIgnore 无显式事务 先查找,存在则忽略,否则插入 (并发性也可以由数据库相同的unique key来保证)
func (*BaseRepo[T]) InsertOrUpdate ¶
func (r *BaseRepo[T]) InsertOrUpdate(insertItem *T, condition map[string]interface{}, updateValues *T) error
InsertOrUpdate 事务版本 先查找,不存在则插入,存在则更新
func (*BaseRepo[T]) SelectBy ¶
func (r *BaseRepo[T]) SelectBy(condition map[string]interface{}, results *[]*T, opts ...SelOpt) error
SelectBy 按照条件查找多条 可使用链式方法添加order和limit等参数
func (*BaseRepo[T]) UpdateById ¶
UpdateById 按照ID更新一条
func (*BaseRepo[T]) UpsertByID ¶
UpsertByID 非显式事务(onConflict和clauses),固定根据id查找记录,如果存在则更新,如果不存在则创建
type IBaseRepo ¶ added in v1.1.20
type IBaseRepo[T any] interface { Exec(sql string, values ...interface{}) (*gorm.DB, error) CountAll() (int64, error) Insert(model *T) error UpdateById(id uint64, updateValues *T) error DeleteById(id uint64) error DeleteBy(condition map[string]interface{}, hardDelete bool) error FindByID(id uint64) (*T, error) FindBy(condition map[string]interface{}) (*T, error) SelectBy(condition map[string]interface{}, results *[]*T, opts ...SelOpt) error InsertOrIgnore(model *T, condition map[string]interface{}) (int64, error) InsertOrUpdate(insertItem *T, condition map[string]interface{}, updateValues *T) error UpsertByID(model *T, updateFields []string) error Upsert(model *T, condition map[string]interface{}) error GetByPage(page int, pageSize int) ([]*T, error) UpdateBy(condition map[string]interface{}, updateValues *T) (int64, error) }
Click to show internal directories.
Click to hide internal directories.