Documentation
¶
Index ¶
- Variables
- type BaseModel
- func (m *BaseModel[T]) DB() *gorm.DB
- func (m *BaseModel[T]) Delete(ctx context.Context, tx *gorm.DB, condition map[string]any) error
- func (m *BaseModel[T]) Exec(ctx context.Context, tx *gorm.DB, sql string, args ...any) error
- func (m *BaseModel[T]) FindAll(ctx context.Context, orderBy string, query string, args ...any) ([]*T, error)
- func (m *BaseModel[T]) FindCount(ctx context.Context, query string, args ...any) (int64, error)
- func (m *BaseModel[T]) FindOne(ctx context.Context, condition map[string]any) (*T, error)
- func (m *BaseModel[T]) FindPage(ctx context.Context, page, pageSize int, orderBy string, query string, ...) ([]*T, int64, error)
- func (m *BaseModel[T]) Insert(ctx context.Context, tx *gorm.DB, data *T) error
- func (m *BaseModel[T]) Query(ctx context.Context, dest any, sql string, args ...any) error
- func (m *BaseModel[T]) Transaction(ctx context.Context, fn func(tx *gorm.DB) error) error
- func (m *BaseModel[T]) Update(ctx context.Context, tx *gorm.DB, data *T) error
- func (m *BaseModel[T]) UpdateColumns(ctx context.Context, tx *gorm.DB, condition map[string]any, ...) error
- type Geometry
- type GeometryColumnsProvider
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrNotFound = errors.New("record not found") ErrInvalidID = errors.New("invalid id") )
Functions ¶
This section is empty.
Types ¶
type BaseModel ¶
type BaseModel[T any] struct { // contains filtered or unexported fields }
BaseModel 泛型基础模型
func (*BaseModel[T]) FindAll ¶
func (m *BaseModel[T]) FindAll(ctx context.Context, orderBy string, query string, args ...any) ([]*T, error)
FindAll 查询所有记录
func (*BaseModel[T]) FindPage ¶
func (m *BaseModel[T]) FindPage(ctx context.Context, page, pageSize int, orderBy string, query string, args ...any) ([]*T, int64, error)
FindPage 分页查询
func (*BaseModel[T]) Transaction ¶
Transaction 事务
type Geometry ¶ added in v0.0.4
type Geometry string
Geometry represents a MySQL geometry type stored as WKT (Well-Known Text) string When querying, use ST_AsText() to convert binary geometry to WKT format
type GeometryColumnsProvider ¶ added in v0.0.4
type GeometryColumnsProvider interface {
GeometryColumns() []string
}
GeometryColumnsProvider interface for models with geometry columns Models implementing this interface will have their geometry columns automatically converted using ST_AsText() in queries
Click to show internal directories.
Click to hide internal directories.