db

package
v0.4.8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 19, 2025 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultConfig added in v0.2.19

func DefaultConfig() *gorm.Config

func FlagSet

func FlagSet(name string) *pflag.FlagSet

func New added in v0.1.11

func New(dialector gorm.Dialector, conn *ConnConfig, opts ...gorm.Option) (*gorm.DB, error)

func NewLogger added in v0.2.19

func NewLogger(isDebug bool) gLogger.Interface

Types

type Config

type Config struct {
	Conn    *ConnConfig       `json:"conn" yaml:"conn"`
	Args    map[string]string `json:"args" yaml:"args"`
	DSN     string            `json:"dsn" yaml:"dsn"`
	User    string            `json:"user" yaml:"user"`
	Pass    string            `json:"pass" yaml:"pass"`
	Name    string            `json:"name" yaml:"name"`
	Debug   bool              `json:"debug" yaml:"debug"`
	Migrate bool              `json:"migrate" yaml:"migrate"`
}

func (*Config) FlagSet added in v0.3.5

func (c *Config) FlagSet(name string) *pflag.FlagSet

func (*Config) GetDB added in v0.3.1

func (c *Config) GetDB() *Config

func (*Config) String added in v0.2.19

func (c *Config) String() string

func (*Config) WithArgs added in v0.2.19

func (c *Config) WithArgs(k, v string) *Config

type ConnConfig

type ConnConfig struct {
	Idle     int `json:"idle" yaml:"idle"`
	Open     int `json:"open" yaml:"open"`
	Lifetime int `json:"lifetime" yaml:"lifetime"`
}

type DialectorWrapper added in v0.2.0

type DialectorWrapper struct {
	gorm.Dialector
	// contains filtered or unexported fields
}

func NewDialectorWrapper added in v0.2.0

func NewDialectorWrapper() *DialectorWrapper

func (*DialectorWrapper) Apply added in v0.2.0

func (d *DialectorWrapper) Apply(dialector gorm.Dialector)

func (*DialectorWrapper) Migrator added in v0.2.0

func (d *DialectorWrapper) Migrator(db *gorm.DB) gorm.Migrator

func (*DialectorWrapper) SetMigrator added in v0.2.0

func (d *DialectorWrapper) SetMigrator(migrator MigratorFunc)

type MigratorFunc added in v0.2.0

type MigratorFunc func(db *gorm.DB) gorm.Migrator

type Model

type Model struct {
	ID        uint64    `gorm:"primaryKey;autoIncrement;column:id"`
	UUID      uuid.UUID `gorm:"type:uuid;unique;column:uuid;default:gen_random_uuid()"`
	CreatedAt int64     `gorm:"autoCreateTime;column:created_at"`
	UpdatedAt int64     `gorm:"autoUpdateTime;column:updated_at"`
}

func (*Model) BeforeCreate

func (m *Model) BeforeCreate(tx *gorm.DB) (err error)

func (*Model) Defaults

func (m *Model) Defaults() []Modeler

func (*Model) GetID

func (m *Model) GetID() uint64

type Modeler

type Modeler interface {
	TableName() string
	Defaults() []Modeler
	GetID() uint64
}

type StringSlice

type StringSlice = datatypes.JSONSlice[string]

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL