Documentation ¶
Index ¶
- type Base
- type BaseRepo
- func (r *BaseRepo[E, T]) Create(ctx context.Context, do E) (E, error)
- func (r *BaseRepo[E, T]) Delete(ctx context.Context, id uint64) error
- func (r *BaseRepo[E, T]) DeleteByIDs(ctx context.Context, ids []uint64) error
- func (r *BaseRepo[E, T]) Exists(ctx context.Context, fieldName string, fieldValue any, ignoreCase ...bool) (bool, error)
- func (r *BaseRepo[E, T]) Find(ctx context.Context, id uint64, lockMode ...LockMode) (E, error)
- func (r *BaseRepo[E, T]) FindByField(ctx context.Context, fieldName string, fieldValue any, args ...any) (E, error)
- func (r *BaseRepo[E, T]) Unique(ctx context.Context, id uint64, fieldName string, fieldValue any, ...) (bool, error)
- func (r *BaseRepo[E, T]) Update(ctx context.Context, m map[string]any) (E, error)
- type LockMode
- type Repo
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Base ¶
type Base struct { Id uint64 `gorm:"primaryKey;autoIncrement:false;comment:分布式全局唯一 ID"` CreatedAt time.Time `gorm:"type:datetime;comment:创建时间"` UpdatedAt time.Time `gorm:"type:datetime;comment:更新时间"` DeletedAt gorm.DeletedAt `gorm:"type:datetime;index;comment:删除时间"` Version optimisticlock.Version `gorm:"default:1;comment:版本号(乐观锁专用)"` }
type BaseRepo ¶
func (*BaseRepo[E, T]) DeleteByIDs ¶
func (*BaseRepo[E, T]) FindByField ¶
type LockMode ¶
type LockMode int32
func ParseLockMode ¶
ParseLockMode attempts to convert a string to a LockMode.
type Repo ¶
type Repo[E, T any] interface { // Exists determines whether po exists (whether to ignore case). Exists(ctx context.Context, fieldName string, fieldValue any, ignoreCase ...bool) (bool, error) // Unique determines whether po is unique (whether to ignore case). Unique(ctx context.Context, id uint64, fieldName string, fieldValue any, ignoreCase ...bool) (bool, error) // Find find po by id (with lockMode). Find(ctx context.Context, id uint64, lockMode ...LockMode) (E, error) // FindByField find po by fieldName and fieldValue (with ignoreCase and/or lockMode). FindByField(ctx context.Context, fieldName string, fieldValue any, args ...any) (E, error) // Create create po. Create(ctx context.Context, do E) (E, error) // Update update po. Update(ctx context.Context, m map[string]any) (E, error) // Delete delete po. Delete(ctx context.Context, id uint64) error // DeleteByIDs delete pos. DeleteByIDs(ctx context.Context, ids []uint64) error }
Repo base repository.
Click to show internal directories.
Click to hide internal directories.