Documentation
¶
Overview ¶
Package db
Package db ¶
Package db ¶
Package db ¶
Package db
Index ¶
- Variables
- type BaseMapper
- type BaseMapperImpl
- func (m *BaseMapperImpl[T]) Count(t *T) (int64, error)
- func (m *BaseMapperImpl[T]) DeleteById(ids ...uuid.UUID) (int64, error)
- func (m *BaseMapperImpl[T]) GetConn() *gorm.DB
- func (m *BaseMapperImpl[T]) GetPage(input page.InputInterface) (*page.Output[T], error)
- func (m *BaseMapperImpl[T]) GetSafeOrderBy(raw string) clause.OrderBy
- func (m *BaseMapperImpl[T]) Insert(e *T) (int64, error)
- func (m *BaseMapperImpl[T]) InsertBatch(list []T) (int64, error)
- func (m *BaseMapperImpl[T]) Select(t *T) ([]T, error)
- func (m *BaseMapperImpl[T]) SelectById(id uuid.UUID) (*T, error)
- func (m *BaseMapperImpl[T]) SelectOne(t *T) (*T, error)
- func (m *BaseMapperImpl[T]) Transaction(f func(tx *gorm.DB) error) error
- func (m *BaseMapperImpl[T]) UpdateByPrimaryKeySelective(t *T) (int64, error)
- type HardDeleteModel
- type JSONB
- func (j *JSONB[T]) Get() T
- func (JSONB[T]) GormDataType() string
- func (j JSONB[T]) GormValue(_ context.Context, _ *gorm.DB) clause.Expr
- func (j JSONB[T]) MarshalJSON() ([]byte, error)
- func (j *JSONB[T]) Scan(value interface{}) error
- func (j *JSONB[T]) Set(value T)
- func (j *JSONB[T]) UnmarshalJSON(data []byte) error
- func (j JSONB[T]) Value() (driver.Value, error)
- type Manager
- type Model
- type ModelConstraint
Constants ¶
This section is empty.
Variables ¶
View Source
var CheckPoint = fxtrategy.ProvideItem[ready.CheckPoint](newCheckpoint, ready.CPGroupName)
CheckPoint 数据库健康检测
View Source
var Module = fx.Module( "db", fx.Provide(InitDataSource), CheckPoint, )
Functions ¶
This section is empty.
Types ¶
type BaseMapper ¶
type BaseMapper[T ModelConstraint] interface { SelectOne(t *T) (*T, error) Select(t *T) ([]T, error) SelectById(id uuid.UUID) (*T, error) GetPage(input page.InputInterface) (*page.Output[T], error) UpdateByPrimaryKeySelective(t *T) (int64, error) DeleteById(ids ...uuid.UUID) (int64, error) Insert(e *T) (int64, error) InsertBatch(list []T) (int64, error) Count(t *T) (int64, error) Transaction(f func(tx *gorm.DB) error) error GetConn() *gorm.DB GetSafeOrderBy(raw string) clause.OrderBy }
func NewBaseMapper ¶
func NewBaseMapper[T ModelConstraint](manager *Manager) BaseMapper[T]
type BaseMapperImpl ¶
type BaseMapperImpl[T ModelConstraint] struct { // contains filtered or unexported fields }
func (*BaseMapperImpl[T]) Count ¶
func (m *BaseMapperImpl[T]) Count(t *T) (int64, error)
func (*BaseMapperImpl[T]) DeleteById ¶
func (m *BaseMapperImpl[T]) DeleteById(ids ...uuid.UUID) (int64, error)
func (*BaseMapperImpl[T]) GetConn ¶
func (m *BaseMapperImpl[T]) GetConn() *gorm.DB
func (*BaseMapperImpl[T]) GetPage ¶
func (m *BaseMapperImpl[T]) GetPage(input page.InputInterface) (*page.Output[T], error)
func (*BaseMapperImpl[T]) GetSafeOrderBy ¶ added in v0.1.4
func (m *BaseMapperImpl[T]) GetSafeOrderBy(raw string) clause.OrderBy
func (*BaseMapperImpl[T]) Insert ¶
func (m *BaseMapperImpl[T]) Insert(e *T) (int64, error)
func (*BaseMapperImpl[T]) InsertBatch ¶
func (m *BaseMapperImpl[T]) InsertBatch(list []T) (int64, error)
func (*BaseMapperImpl[T]) Select ¶
func (m *BaseMapperImpl[T]) Select(t *T) ([]T, error)
func (*BaseMapperImpl[T]) SelectById ¶
func (m *BaseMapperImpl[T]) SelectById(id uuid.UUID) (*T, error)
func (*BaseMapperImpl[T]) SelectOne ¶
func (m *BaseMapperImpl[T]) SelectOne(t *T) (*T, error)
func (*BaseMapperImpl[T]) Transaction ¶
func (m *BaseMapperImpl[T]) Transaction(f func(tx *gorm.DB) error) error
func (*BaseMapperImpl[T]) UpdateByPrimaryKeySelective ¶
func (m *BaseMapperImpl[T]) UpdateByPrimaryKeySelective(t *T) (int64, error)
type HardDeleteModel ¶
type HardDeleteModel struct {
CreatedAt time.Time `json:"createdAt" gorm:"type:timestamptz"`
UpdatedAt time.Time `json:"updatedAt" gorm:"type:timestamptz"`
}
HardDeleteModel 适合需要硬删除的场景
func (HardDeleteModel) HasChanged ¶
func (m HardDeleteModel) HasChanged() bool
func (HardDeleteModel) IsDel ¶
func (m HardDeleteModel) IsDel() bool
type JSONB ¶
type JSONB[T any] struct { // contains filtered or unexported fields }
func (JSONB[T]) GormDataType ¶
func (JSONB[T]) MarshalJSON ¶
MarshalJSON returns m as the JSON encoding of m.
func (*JSONB[T]) UnmarshalJSON ¶
UnmarshalJSON sets *m to a copy of data.
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager 数据库连接管理 database/sql 级别的DB,Stmt都是并发安全的
func InitDataSource ¶
type Model ¶
type Model struct {
CreatedAt time.Time `json:"createdAt" gorm:"type:timestamptz"`
UpdatedAt time.Time `json:"updatedAt" gorm:"type:timestamptz"`
DeletedAt gorm.DeletedAt `json:"deletedAt"`
}
Model is recommended basic fields for every table
func (Model) HasChanged ¶
type ModelConstraint ¶
Directories
¶
| Path | Synopsis |
|---|---|
|
helper
|
|
|
page
Package page
|
Package page |
|
sqlBuilder
Package sqlBuilder
|
Package sqlBuilder |
Click to show internal directories.
Click to hide internal directories.