Documentation ¶
Index ¶
- Variables
- func RegisterDriver(name string, dr DriverRegister)
- 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 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 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() (*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"` LogChannel string `yaml:"log_channel"` }
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"` }
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]
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.