Documentation ¶
Index ¶
- type BaseRepo
- func (r *BaseRepo[T]) CountAll() (int64, error)
- func (r *BaseRepo[T]) DeleteBy(condition *T, 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 *T) (*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 *T) (int64, error)
- func (r *BaseRepo[T]) InsertOrUpdate(insertItem *T, condition *T, updateValues *T) error
- func (r *BaseRepo[T]) SelectBy(condition *T, results *[]*T, opts ...SelOpt) error
- func (r *BaseRepo[T]) UpdateBy(condition *T, updateValues *T) (int64, error)
- func (r *BaseRepo[T]) UpdateById(id uint64, updateValues *T) error
- func (r *BaseRepo[T]) Upsert(model *T, condition *T) error
- func (r *BaseRepo[T]) UpsertByID(model *T, updateFields []string) error
- type SelOpt
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BaseRepo ¶
func NewBaseRepo ¶
func (*BaseRepo[T]) DeleteById ¶
DeleteById 按照ID删除一条
func (*BaseRepo[T]) InsertOrIgnore ¶
InsertOrIgnore 无显式事务 先查找,存在则忽略,否则插入 (并发性也可以由数据库相同的unique key来保证)
func (*BaseRepo[T]) InsertOrUpdate ¶
InsertOrUpdate 事务版本 先查找,不存在则插入,存在则更新
func (*BaseRepo[T]) UpdateById ¶
UpdateById 按照ID更新一条
func (*BaseRepo[T]) UpsertByID ¶
UpsertByID 非显式事务(onConflict和clauses),固定根据id查找记录,如果存在则更新,如果不存在则创建
Click to show internal directories.
Click to hide internal directories.