Documentation ¶
Index ¶
- Constants
- func GetNotFoundErr(err error) *errorx.Error
- func IsNotFoundErr(err error, errCode int32) bool
- func ScopeTxGo(db *gorm.DB, callbacks ...TxCallback) error
- func TxGo(db *gorm.DB, executes ...TxHandler) error
- type GenerateIDFunc
- type IModel
- type ITModel
- type ModelBase
- type OrderColumn
- type ProtoDeletedAt
- type ProtoUpsertedAt
- type QueryOpts
- type Scope
- func (s *Scope) Association(value string) *Scope
- func (s *Scope) Between(field string, arg1, arg2 interface{}) *Scope
- func (s *Scope) Clause(value ...clause.Expression) *Scope
- func (s *Scope) Count() (total int64, err error)
- func (s *Scope) Create(v interface{}) error
- func (s *Scope) CreateInBatches(values interface{}, batchSize int) error
- func (s *Scope) Delete(conds ...interface{}) error
- func (s *Scope) Eq(field string, arg interface{}) *Scope
- func (s *Scope) Exist(conds ...interface{}) (bool, error)
- func (s *Scope) Find(dest interface{}, conds ...interface{}) error
- func (s *Scope) First(dest interface{}, conds ...interface{}) error
- func (s *Scope) Group(name string) *Scope
- func (s *Scope) Groups(names ...string) *Scope
- func (s *Scope) Gt(field string, arg interface{}) *Scope
- func (s *Scope) Gte(field string, arg interface{}) *Scope
- func (s *Scope) HandlePagination(opt *pagination.Pagination) *pagination.Pagination
- func (s *Scope) Having(query interface{}, args ...interface{}) *Scope
- func (s *Scope) IgnoreNotFoundErr() *Scope
- func (s *Scope) In(field string, values interface{}) *Scope
- func (s *Scope) Joins(query string, args ...interface{}) *Scope
- func (s *Scope) Like(field string, value string) *Scope
- func (s *Scope) LikePrefix(field string, value string) *Scope
- func (s *Scope) Limit(limit int) *Scope
- func (s *Scope) Lt(field string, arg interface{}) *Scope
- func (s *Scope) Lte(field string, arg interface{}) *Scope
- func (s *Scope) MultiOr(opts map[string]interface{}) *Scope
- func (s *Scope) MultiOrLike(opts map[string]string, isPrefix bool) *Scope
- func (s *Scope) Ne(field string, arg interface{}) *Scope
- func (s *Scope) NotBetween(field string, arg1, arg2 interface{}) *Scope
- func (s *Scope) NotIn(field string, values interface{}) *Scope
- func (s *Scope) Offset(offset int) *Scope
- func (s *Scope) Omit(value ...string) *Scope
- func (s *Scope) Or(query interface{}, args ...interface{}) *Scope
- func (s *Scope) Order(value string) *Scope
- func (s *Scope) Orders(values ...OrderColumn) *Scope
- func (s *Scope) PaginationQuery(opt *pagination.Pagination, list interface{}) (*pagination.Pagination, error)
- func (s *Scope) Preload(query string, args ...interface{}) *Scope
- func (s *Scope) Query(opts *QueryOpts) *Scope
- func (s *Scope) ResetSysDateTimeField(v interface{})
- func (s *Scope) ReturnColumns(columns ...string) *Scope
- func (s *Scope) Select(fields ...string) *Scope
- func (s *Scope) SetGenerateIDFunc(idFunc GenerateIDFunc) *Scope
- func (s *Scope) SetNotFoundErr(notFoundErrCode int32) *Scope
- func (s *Scope) Unscoped() *Scope
- func (s *Scope) Update(v interface{}, conds ...interface{}) error
- func (s *Scope) Where(query interface{}, args ...interface{}) *Scope
- type T
- func (x *T) BatchCreate(list interface{}) (err error)
- func (x *T) CloneTModel() interface{}
- func (x *T) Count(whereMap map[string]interface{}) (int64, error)
- func (x *T) Create(m interface{}) (err error)
- func (x *T) DeleteByPk(pk interface{}) error
- func (x *T) DeleteByWhere(query interface{}, args ...interface{}) error
- func (x *T) ExistByWhere(query interface{}, args ...interface{}) (bool, error)
- func (x *T) GetOne(pk uint64, m interface{}) error
- func (x *T) GetOneByWhere(whereMap map[string]interface{}, m interface{}) error
- func (x *T) ListAll(opts interface{}, listPtr interface{}) error
- func (x *T) ListWithPagination(paginate *pagination.Pagination, opts interface{}, listPtr interface{}) (*pagination.Pagination, error)
- func (x *T) Scope() *Scope
- func (x *T) SetCreateBatchSize(size int)
- func (x *T) Update(m interface{}, whereMap map[string]interface{}) (rows int64, err error)
- type TxCallback
- type TxHandler
Constants ¶
View Source
const ( DefaultLimit uint32 = 2000 MaxLimit uint32 = 100000 )
View Source
const ( ProtoMessageFieldCreatedAt = "created_at" ProtoMessageFieldUpdatedAt = "updated_at" ProtoMessageFieldDeletedAt = "deleted_at" )
Variables ¶
This section is empty.
Functions ¶
func GetNotFoundErr ¶
func IsNotFoundErr ¶
IsNotFoundErr returns true if err is an *Error and its ErrorCode matches ErrCodeRecordNotFoundSys or errCode.
Types ¶
type ModelBase ¶
type ModelBase interface { ProtoReflect() protoreflect.Message GetId() uint64 }
type OrderColumn ¶
type ProtoDeletedAt ¶
type ProtoDeletedAt interface {
GetDeletedAt() uint32
}
type ProtoUpsertedAt ¶
type ProtoUpsertedAt interface { ProtoReflect() protoreflect.Message GetCreatedAt() uint32 GetUpdatedAt() uint32 ProtoDeletedAt }
type Scope ¶
func NewScopeOfPure ¶
func (*Scope) Association ¶
func (*Scope) CreateInBatches ¶
CreateInBatches Insert data in batches after splitting data according to batchSize
func (*Scope) HandlePagination ¶
func (s *Scope) HandlePagination(opt *pagination.Pagination) *pagination.Pagination
func (*Scope) IgnoreNotFoundErr ¶
func (*Scope) MultiOrLike ¶
func (*Scope) NotBetween ¶
func (*Scope) Orders ¶
func (s *Scope) Orders(values ...OrderColumn) *Scope
func (*Scope) PaginationQuery ¶
func (s *Scope) PaginationQuery(opt *pagination.Pagination, list interface{}) (*pagination.Pagination, error)
func (*Scope) ResetSysDateTimeField ¶
func (s *Scope) ResetSysDateTimeField(v interface{})
ResetSysDateTimeField To prevent someone from passing in these three fields by mistake, this method is provided to reset
func (*Scope) ReturnColumns ¶
ReturnColumns Return data, return all field data without passing columns
func (*Scope) SetGenerateIDFunc ¶
func (s *Scope) SetGenerateIDFunc(idFunc GenerateIDFunc) *Scope
func (*Scope) SetNotFoundErr ¶
type T ¶
type T struct { NotFoundErrCode int32 BatchCreateSize int PrimaryKey string // contains filtered or unexported fields }
func (*T) BatchCreate ¶
func (*T) CloneTModel ¶
func (x *T) CloneTModel() interface{}
func (*T) DeleteByPk ¶
func (*T) DeleteByWhere ¶
func (*T) ExistByWhere ¶
func (*T) GetOneByWhere ¶
func (*T) ListWithPagination ¶
func (x *T) ListWithPagination(paginate *pagination.Pagination, opts interface{}, listPtr interface{}) (*pagination.Pagination, error)
func (*T) SetCreateBatchSize ¶
type TxCallback ¶
Click to show internal directories.
Click to hide internal directories.