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{}, results *[]*T, opts ...FindOption) error
- func (r *BaseRepo[T]) FindByID(id uint64) (*T, error)
- func (r *BaseRepo[T]) GetByPage(model interface{}, page int, pageSize int) (interface{}, 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(model *T, condition map[string]interface{}, ...) error
- func (r *BaseRepo[T]) UpdateById(model *T, id uint64) error
- func (r *BaseRepo[T]) Upsert(model *T, condition map[string]interface{}) error
- type FindOption
- type IBaseRepo
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]) FindBy ¶
func (r *BaseRepo[T]) FindBy(condition map[string]interface{}, results *[]*T, opts ...FindOption) error
FindBy 按照条件查找多条 _order_by 为自定义快捷键 可以添加到条件中无需每次调用都额外写空参数
func (*BaseRepo[T]) InsertOrIgnore ¶
InsertOrIgnore 事务版本 先查找,存在则忽略,否则插入
func (*BaseRepo[T]) InsertOrUpdate ¶
func (r *BaseRepo[T]) InsertOrUpdate(model *T, condition map[string]interface{}, updateValues map[string]interface{}) error
InsertOrUpdate 事务版本 先查找,不存在则插入,插入则更新
func (*BaseRepo[T]) UpdateById ¶
UpdateById 按照ID更新一条
type FindOption ¶ added in v1.1.20
FindOption FindBy 条件配置
func WithLimit ¶
func WithLimit(limit int) FindOption
func WithOrderBy ¶
func WithOrderBy(orderBy string) FindOption
type IBaseRepo ¶ added in v1.1.20
type IBaseRepo interface { Insert(model interface{}) error InsertOrUpdate(model interface{}, condition map[string]interface{}, forUpdateValues interface{}) error UpdateById(model interface{}, id uint64) error DeleteById(model interface{}, id uint64) error DeleteBy(condition map[string]interface{}, model interface{}, hardDelete bool) error SelectById(model interface{}, id uint64) error SelectBy(condition map[string]interface{}) ([]interface{}, error) SelectOne(condition map[string]interface{}, model interface{}) error }
Click to show internal directories.
Click to hide internal directories.