Documentation
¶
Index ¶
- Constants
- func AndConditionBy(param any) clause.Expression
- func ByName(name string) clause.Expression
- func ByPrimary(id any) clause.Expression
- func ByPrimaryKey(v any) clause.Expression
- func ConditionsBy(param any) []clause.Expression
- func Delete(db *gorm.DB, tableName string, column string, value any) error
- func DeleteByPrimary(db *gorm.DB, tableName string, primary any) error
- func Exists(db *gorm.DB, tableName, column string, value any, withDeletedAt bool) (bool, error)
- func ExistsByColumn(db *gorm.DB, tableName, column string, value any) (bool, error)
- func ExistsByColumnWithDeletedAt(db *gorm.DB, tableName, column string, value any) (bool, error)
- func ExistsByFilterExprs(db *gorm.DB, tableName string, filters sqlx.FilterExprs) (bool, error)
- func ExistsByQuery(db *gorm.DB, qsql string, value ...any) (bool, error)
- func ExistsBySQL(db *gorm.DB, sql string, value ...any) (bool, error)
- func FindList[T any](db *gorm.DB, list *sqlx.List) ([]T, int64, error)
- func Generator(db *gorm.DB, outPath, modelPkgPath string, tables ...string) error
- func GetByPrimary[T any](db *gorm.DB, primary any) (*T, error)
- func New(loger *zap.Logger, conf *logger.Config) logger.Interface
- func NewCondition(field string, op sqlx.ConditionOperation, args any) clause.Expression
- func NotConditionBy(param any) clause.Expression
- func OrConditionBy(param any) clause.Expression
- func PaginationExpr(pageNo, pageSize uint32) clause.Expression
- func SingleSortExpr(field string, sortType sqlx.SortType) clause.Expression
- func SortExpr(expr clause.Expression, sorts ...sqlx.Sort) clause.Expression
- func TableName(tx *gorm.DB, name string) *gorm.DB
- type Between
- type Clause
- type Clauses
- type ConditionExpr
- type ConditionsExpr
- type Config
- type CustomMetric
- type DateSerializer
- type FilterExpr
- type FilterExprs
- type GlobalMetrics
- type IsNotNull
- type IsNull
- type JSONSerializer
- type Json
- type Limit
- type Location
- type Logger
- func (l *Logger) Error(ctx context.Context, msg string, data ...interface{})
- func (l *Logger) Info(ctx context.Context, msg string, data ...interface{})
- func (l *Logger) LogMode(level logger.LogLevel) logger.Interface
- func (l *Logger) Trace(ctx context.Context, begin time.Time, fc func() (string, int64), err error)
- func (l *Logger) Warn(ctx context.Context, msg string, data ...interface{})
- type Not
- type NotLike
- type OTelPlugin
- type Option
- func WithAttributes(attrs ...attribute.KeyValue) Option
- func WithCustomMetrics(metrics ...CustomMetric) Option
- func WithDBSystem(name string) Option
- func WithQueryFormatter(fn func(query string) string) Option
- func WithRecordStackTrace() Option
- func WithServerAddressProvider(fn func(dialector gorm.Dialector) string) Option
- func WithTracerProvider(provider trace.TracerProvider) Option
- func WithoutMetrics() Option
- func WithoutQueryVariables() Option
- type Pagination
- type PaginationEmbedded
- type Range
- type RecordContext
- type Sort
- type Sorts
- type StringArraySerializer
- type UnixMilliTimeSerializer
Constants ¶
const ScopeName = "github.com/hopeio/gox/database/sql/gorm"
Variables ¶
This section is empty.
Functions ¶
func AndConditionBy ¶ added in v1.10.0
func AndConditionBy(param any) clause.Expression
AndConditionBy returns the result.
func ByName ¶ added in v1.10.0
func ByName(name string) clause.Expression
ByName returns the result.
func ByPrimary ¶ added in v1.10.0
func ByPrimary(id any) clause.Expression
ByPrimary returns the result.
func ByPrimaryKey ¶ added in v1.10.0
func ByPrimaryKey(v any) clause.Expression
ByPrimaryKey returns the result.
func ConditionsBy ¶ added in v1.10.0
func ConditionsBy(param any) []clause.Expression
ConditionsBy returns the result.
func DeleteByPrimary ¶ added in v1.10.0
DeleteByPrimary removes or resets state.
func ExistsByColumn ¶
ExistsByColumn performs the operation.
func ExistsByColumnWithDeletedAt ¶
ExistsByColumnWithDeletedAt performs the operation.
func ExistsByFilterExprs ¶
ExistsByFilterExprs performs the operation.
func ExistsByQuery ¶
ExistsByQuery performs the operation.
func ExistsBySQL ¶
ExistsBySQL performs the operation.
func GetByPrimary ¶ added in v1.10.0
GetByPrimary returns the value.
func NewCondition ¶ added in v1.10.0
func NewCondition(field string, op sqlx.ConditionOperation, args any) clause.Expression
NewCondition creates and returns a new instance.
func NotConditionBy ¶ added in v1.10.0
func NotConditionBy(param any) clause.Expression
NotConditionBy returns the result.
func OrConditionBy ¶ added in v1.10.0
func OrConditionBy(param any) clause.Expression
OrConditionBy returns the result.
func PaginationExpr ¶ added in v1.10.0
func PaginationExpr(pageNo, pageSize uint32) clause.Expression
PaginationExpr returns the result.
func SingleSortExpr ¶ added in v1.10.0
func SingleSortExpr(field string, sortType sqlx.SortType) clause.Expression
SingleSortExpr returns the result.
func SortExpr ¶ added in v1.10.0
func SortExpr(expr clause.Expression, sorts ...sqlx.Sort) clause.Expression
SortExpr returns the result.
Types ¶
type Between ¶ added in v1.10.0
func (Between) NegationBuild ¶ added in v1.10.0
NegationBuild performs the operation.
type Clause ¶ added in v1.10.0
type Clause interface {
Clause() clause.Expression
}
type Clauses ¶ added in v1.10.0
type Clauses interface {
Clauses() []clause.Expression
}
type ConditionExpr ¶ added in v1.10.0
type ConditionExpr interface {
Condition() clause.Expression
}
type ConditionsExpr ¶ added in v1.10.0
type ConditionsExpr interface {
Conditions() []clause.Expression
}
type CustomMetric ¶ added in v1.10.2
type CustomMetric interface {
Record(*RecordContext)
}
type DateSerializer ¶ added in v1.11.8
type DateSerializer struct {
}
type FilterExpr ¶ added in v1.10.0
type FilterExpr sqlx.FilterExpr
func (*FilterExpr) Condition ¶ added in v1.10.0
func (f *FilterExpr) Condition() clause.Expression
Condition returns the result.
type FilterExprs ¶ added in v1.10.0
type FilterExprs sqlx.FilterExprs
func (FilterExprs) Apply ¶ added in v1.10.0
func (f FilterExprs) Apply(db *gorm.DB) *gorm.DB
Apply returns the result.
func (FilterExprs) Condition ¶ added in v1.10.0
func (f FilterExprs) Condition() clause.Expression
Condition returns the result.
func (FilterExprs) Conditions ¶ added in v1.10.0
func (f FilterExprs) Conditions() []clause.Expression
Conditions returns the result.
type GlobalMetrics ¶ added in v1.11.0
type GlobalMetrics struct {
// contains filtered or unexported fields
}
func GlobalGormMetrics ¶ added in v1.11.0
func GlobalGormMetrics() *GlobalMetrics
GlobalGormMetrics returns the result.
type IsNotNull ¶ added in v1.10.0
type IsNotNull IsNull
func (IsNotNull) NegationBuild ¶ added in v1.10.0
NegationBuild performs the operation.
type IsNull ¶ added in v1.10.0
type IsNull struct {
Column any
}
func (IsNull) NegationBuild ¶ added in v1.10.0
NegationBuild performs the operation.
type JSONSerializer ¶ added in v1.10.0
type JSONSerializer struct {
}
JSONSerializer is a JSON serializer
type Json ¶ added in v1.10.0
func (*Json[T]) GormDBDataType ¶ added in v1.10.0
GormDBDataType returns the result.
type Limit ¶ added in v1.10.0
Limit limit clause
func (Limit) MergeClause ¶ added in v1.10.0
MergeClause merge order by clauses
type Location ¶ added in v1.10.0
type Location struct {
X, Y float64
}
func (Location) GormDataType ¶ added in v1.10.0
GormDataType returns the result.
type Logger ¶ added in v1.10.0
type Not ¶ added in v1.10.0
type Not struct {
Expr clause.NegationExpressionBuilder
}
type OTelPlugin ¶ added in v1.10.2
type OTelPlugin struct {
// contains filtered or unexported fields
}
func NewOTelPlugin ¶ added in v1.10.2
func NewOTelPlugin(opts ...Option) *OTelPlugin
NewOTelPlugin creates and returns a new instance.
func (*OTelPlugin) Close ¶ added in v1.10.2
func (p *OTelPlugin) Close(ctx context.Context) error
Close closes and releases resources.
func (*OTelPlugin) Initialize ¶ added in v1.10.2
func (p *OTelPlugin) Initialize(db *gorm.DB) error
Initialize performs the operation.
func (*OTelPlugin) Name ¶ added in v1.10.2
func (p *OTelPlugin) Name() string
Name returns the result.
type Option ¶ added in v1.10.2
type Option func(*OTelPlugin)
func WithAttributes ¶ added in v1.10.2
WithAttributes updates or inserts a value.
func WithCustomMetrics ¶ added in v1.10.2
func WithCustomMetrics(metrics ...CustomMetric) Option
WithCustomMetrics updates or inserts a value.
func WithDBSystem ¶ added in v1.12.0
WithDBSystem updates or inserts a value.
func WithQueryFormatter ¶ added in v1.12.0
WithQueryFormatter updates or inserts a value.
func WithRecordStackTrace ¶ added in v1.12.0
func WithRecordStackTrace() Option
WithRecordStackTrace updates or inserts a value.
func WithServerAddressProvider ¶ added in v1.12.0
WithServerAddressProvider updates or inserts a value.
func WithTracerProvider ¶ added in v1.12.0
func WithTracerProvider(provider trace.TracerProvider) Option
WithTracerProvider updates or inserts a value.
func WithoutMetrics ¶ added in v1.12.0
func WithoutMetrics() Option
WithoutMetrics updates or inserts a value.
func WithoutQueryVariables ¶ added in v1.12.0
func WithoutQueryVariables() Option
WithoutQueryVariables updates or inserts a value.
type Pagination ¶ added in v1.10.0
type Pagination sqlx.Pagination
func (*Pagination) Apply ¶ added in v1.10.0
func (req *Pagination) Apply(db *gorm.DB) *gorm.DB
Apply returns the result.
func (*Pagination) Clause ¶ added in v1.10.0
func (req *Pagination) Clause() clause.Expression
Clause returns the result.
type PaginationEmbedded ¶ added in v1.10.0
type PaginationEmbedded sqlx.PaginationEmbedded
func (*PaginationEmbedded) ToPagination ¶ added in v1.10.0
func (req *PaginationEmbedded) ToPagination() *Pagination
ToPagination converts the value.
type Range ¶ added in v1.10.0
func (*Range[T]) Condition ¶ added in v1.10.0
func (req *Range[T]) Condition() clause.Expression
Condition returns the result.
type RecordContext ¶ added in v1.10.2
type Sort ¶ added in v1.10.0
func (*Sort) Clause ¶ added in v1.10.0
func (o *Sort) Clause() clause.Expression
Clause returns the result.
type Sorts ¶ added in v1.10.0
func (Sorts) Clause ¶ added in v1.10.0
func (o Sorts) Clause() clause.Expression
Clause returns the result.
type StringArraySerializer ¶ added in v1.10.0
type StringArraySerializer struct {
}
StringArraySerializer is an array serializer
type UnixMilliTimeSerializer ¶ added in v1.11.8
type UnixMilliTimeSerializer struct {
}