Documentation ¶
Index ¶
- Variables
- func RegisterDriver(name string, dr DriverRegister)
- func RegisterFromConfig(name string, config ConnectionConfig, defaultLogger *zap.Logger)
- func WithDefaults()
- type Builder
- type Config
- type ConnectionConfig
- type DriverRegister
- type Injector
- type Logger
- func (l *Logger) Error(_ context.Context, msg string, data ...interface{})
- func (l *Logger) Info(_ 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, ...)
- func (l *Logger) Warn(_ context.Context, msg string, data ...interface{})
- type Model
- type PageMeta
- type PageParams
- type PageResult
- type PaginateOptions
- type Paginator
- type RequestPageParams
- type Service
Constants ¶
This section is empty.
Variables ¶
View Source
var ( MaxIdelConns = 10 MaxOpenConns = 100 MaxLifeTime = time.Hour MaxIdleTime = time.Hour )
View Source
var ( DefaultPageSize = 15 PageKey = "page" PageSizeKey = "per_page" PageParamsType = reflection.InterfaceType[PageParams]() )
View Source
var DestSliceType = reflect.TypeOf([]interface{}{})
View Source
var Migrator func(tx *gorm.DB)
View Source
var ModelType = reflect.TypeOf(Model{})
Functions ¶
func RegisterDriver ¶ added in v0.0.5
func RegisterDriver(name string, dr DriverRegister)
RegisterDriver register db driver
func RegisterFromConfig ¶ added in v0.1.19
func RegisterFromConfig(name string, config ConnectionConfig, defaultLogger *zap.Logger)
func WithDefaults ¶ added in v0.0.7
func WithDefaults()
Types ¶
type Builder ¶ added in v0.1.0
func NewBuilder ¶ added in v0.1.0
func (*Builder[T]) Paginate ¶ added in v0.1.0
func (b *Builder[T]) Paginate(opts ...PaginateOptions) (*PageResult[T], error)
type Config ¶ added in v0.0.5
type Config struct { Default string `yaml:"default" env:"DB_CONNECTION"` Connections map[string]*ConnectionConfig `yaml:"connections"` //ImplicitInjection: whether injection model to request handler implicit // usage: // w.Get("/users/:user", func(user models.User) models.User { // return user // }) // ImplicitInjection bool `yaml:"implicit_injection"` AuthMigrate bool `yaml:"migrate" env:"DB_MIGRATE"` LogChannel string `yaml:"log_channel"` WithForeignKey bool `yaml:"with_foreign_key" default:"false"` WithMigrationLog bool `yaml:"with_migration_log" default:"false"` }
type ConnectionConfig ¶ added in v0.0.5
type DriverRegister ¶ added in v0.0.5
func GetDriverRegister ¶ added in v0.0.5
func GetDriverRegister(name string) (DriverRegister, bool)
GetDriverRegister: get registerd driver
type Injector ¶ added in v0.0.2
type Injector struct {
// contains filtered or unexported fields
}
type Logger ¶ added in v0.1.0
type Model ¶ added in v0.0.7
type PageParams ¶ added in v0.1.0
type PageResult ¶ added in v0.1.0
type PageResult[T interface{}] struct { Meta PageMeta `json:"meta"` Data []T `json:"data"` Extra map[string]interface{} `json:"extra,omitempty"` }
func (*PageResult[T]) With ¶ added in v0.1.2
func (pr *PageResult[T]) With(key string, data interface{}) *PageResult[T]
func (*PageResult[T]) WithOut ¶ added in v0.1.2
func (pr *PageResult[T]) WithOut(key string) *PageResult[T]
type PaginateOptions ¶ added in v0.1.10
type Paginator ¶ added in v0.1.0
type Paginator[T interface{}] struct {
Params PageParams
}
func NewPaginator ¶ added in v0.1.0
func NewPaginator[T interface{}](params PageParams) Paginator[T]
func (Paginator[T]) Paginate ¶ added in v0.1.0
func (p Paginator[T]) Paginate(tx *gorm.DB, opts ...PaginateOptions) (*PageResult[T], error)
type RequestPageParams ¶ added in v0.1.0
type RequestPageParams struct {
// contains filtered or unexported fields
}
func (RequestPageParams) Page ¶ added in v0.1.0
func (r RequestPageParams) Page() int
func (RequestPageParams) PerPage ¶ added in v0.1.0
func (r RequestPageParams) PerPage() int
type Service ¶ added in v0.0.5
type Service struct {
// contains filtered or unexported fields
}
Service of database
func NewService ¶ added in v0.0.7
func NewService() *Service
Click to show internal directories.
Click to hide internal directories.