Documentation ¶
Index ¶
- func Apply(db *gorm.DB, conditions ...any) (newDB *gorm.DB, err error)
- func WithE2M[PO any, Entity any](f func(dst *PO, src *Entity) error) func(*Repository[PO, Entity])
- func WithIsolation(level sql.IsolationLevel) func(*sql.TxOptions)
- func WithM2E[PO any, Entity any](f func(dst *Entity, src *PO) error) func(*Repository[PO, Entity])
- func WithPrefix(prefix string) func(*Module)
- func WithReadOnly(readOnly bool) func(*sql.TxOptions)
- type CommonField
- type GormDBHolder
- func (d *GormDBHolder) Begin(sets ...func(*sql.TxOptions))
- func (d *GormDBHolder) BeginTx(sets ...func(*sql.TxOptions)) (tx *gorm.DB)
- func (d *GormDBHolder) Commit() error
- func (d *GormDBHolder) GetDB() (db *gorm.DB)
- func (d *GormDBHolder) Rollback() error
- func (d *GormDBHolder) Transaction(f func() error, sets ...func(*sql.TxOptions)) (err error)
- func (d *GormDBHolder) TransactionTx(f func(tx *gorm.DB) error, sets ...func(*sql.TxOptions)) (err error)
- type JoinWhere
- type Module
- type Repository
- func (r *Repository[PO, Entity]) Create(entities ...*Entity) (err error)
- func (r *Repository[PO, Entity]) Delete(conditions ...any) (err error)
- func (r *Repository[PO, Entity]) E2M(dst *PO, src *Entity) (err error)
- func (r *Repository[PO, Entity]) First(conditions ...any) (entity *Entity, err error)
- func (r *Repository[PO, Entity]) List(conditions ...any) (list []*Entity, err error)
- func (r *Repository[PO, Entity]) M2E(dst *Entity, src *PO) (err error)
- func (r *Repository[PO, Entity]) Pagination(offset, limit int, conditions ...any) (total int64, list []*Entity, err error)
- func (r *Repository[PO, Entity]) Update(entity any, conditions ...any) (err error)
- type SnowflakeID
- type UnixTimestampMilli
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func WithE2M ¶
func WithE2M[PO any, Entity any](f func(dst *PO, src *Entity) error) func(*Repository[PO, Entity])
func WithIsolation ¶
func WithIsolation(level sql.IsolationLevel) func(*sql.TxOptions)
func WithM2E ¶
func WithM2E[PO any, Entity any](f func(dst *Entity, src *PO) error) func(*Repository[PO, Entity])
func WithPrefix ¶
func WithReadOnly ¶
Types ¶
type CommonField ¶
type CommonField struct { SnowflakeID CreatedAt int64 `json:"created_at" gorm:"autoCreateTime"` UpdatedAt int64 `json:"updated_at" gorm:"autoUpdateTime"` }
type GormDBHolder ¶
type GormDBHolder struct {
// contains filtered or unexported fields
}
func NewGormDBHolder ¶
func NewGormDBHolder(db *gorm.DB) *GormDBHolder
func (*GormDBHolder) Begin ¶
func (d *GormDBHolder) Begin(sets ...func(*sql.TxOptions))
func (*GormDBHolder) BeginTx ¶
func (d *GormDBHolder) BeginTx(sets ...func(*sql.TxOptions)) (tx *gorm.DB)
func (*GormDBHolder) Commit ¶
func (d *GormDBHolder) Commit() error
func (*GormDBHolder) GetDB ¶
func (d *GormDBHolder) GetDB() (db *gorm.DB)
func (*GormDBHolder) Rollback ¶
func (d *GormDBHolder) Rollback() error
func (*GormDBHolder) Transaction ¶
func (d *GormDBHolder) Transaction(f func() error, sets ...func(*sql.TxOptions)) (err error)
func (*GormDBHolder) TransactionTx ¶
type Repository ¶
type Repository[PO any, Entity any] struct { *GormDBHolder // contains filtered or unexported fields }
func NewRepository ¶
func NewRepository[PO any, Entity any](opts ...func(*Repository[PO, Entity])) *Repository[PO, Entity]
func (*Repository[PO, Entity]) Create ¶
func (r *Repository[PO, Entity]) Create(entities ...*Entity) (err error)
func (*Repository[PO, Entity]) Delete ¶
func (r *Repository[PO, Entity]) Delete(conditions ...any) (err error)
func (*Repository[PO, Entity]) E2M ¶
func (r *Repository[PO, Entity]) E2M(dst *PO, src *Entity) (err error)
func (*Repository[PO, Entity]) First ¶
func (r *Repository[PO, Entity]) First(conditions ...any) (entity *Entity, err error)
func (*Repository[PO, Entity]) List ¶
func (r *Repository[PO, Entity]) List(conditions ...any) (list []*Entity, err error)
func (*Repository[PO, Entity]) M2E ¶
func (r *Repository[PO, Entity]) M2E(dst *Entity, src *PO) (err error)
func (*Repository[PO, Entity]) Pagination ¶
func (r *Repository[PO, Entity]) Pagination(offset, limit int, conditions ...any) (total int64, list []*Entity, err error)
type SnowflakeID ¶
type SnowflakeID struct {
ID uint64 `json:"id,string" gorm:"primaryKey;autoIncrement:false"`
}
func (*SnowflakeID) BeforeCreate ¶
func (s *SnowflakeID) BeforeCreate(tx *gorm.DB) (err error)
type UnixTimestampMilli ¶
Click to show internal directories.
Click to hide internal directories.