database

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2024 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrUnexpectedType = errors.New("unexpected data type")
	UnixEpoch         = time.UnixMilli(0)
)

Functions

func NewMySQLDriver

func NewMySQLDriver(lc fx.Lifecycle, opt Option, logger *slog.Logger) (*xorm.Engine, error)

Types

type NullTimestamp

type NullTimestamp struct {
	Time  time.Time
	Valid bool
}

NullTimestamp represents a Timestamp that may be null.

func NewNullTimestamp

func NewNullTimestamp(t time.Time) NullTimestamp

func (*NullTimestamp) FromDB

func (ts *NullTimestamp) FromDB(data []byte) error

func (*NullTimestamp) Scan

func (ts *NullTimestamp) Scan(src any) error

func (*NullTimestamp) ToDB

func (ts *NullTimestamp) ToDB() ([]byte, error)

func (*NullTimestamp) Value

func (ts *NullTimestamp) Value() (driver.Value, error)

type Option

type Option struct {
	Host         string `json:"host" yaml:"host" toml:"host"`
	Port         int    `json:"port,string" yaml:"port" toml:"port"`
	User         string `json:"user" yaml:"user" toml:"user"`
	Password     string `json:"password" yaml:"password" toml:"password"`
	Database     string `json:"database" yaml:"database" toml:"database"`
	MaxOpenConns int    `json:"max_open_conns" yaml:"max_open_conns" toml:"max_open_conns"`
	MaxIdleConns int    `json:"max_idle_conns" yaml:"max_idle_conns" toml:"max_idle_conns"`
	MaxIdleTime  string `json:"max_idle_time" yaml:"max_idle_time" toml:"max_idle_time"`
	MaxLifetime  string `json:"max_lifetime" yaml:"max_lifetime" toml:"max_lifetime"`
}

type Timestamp

type Timestamp struct {
	Time time.Time
}

Timestamp is a type that represents a timestamp in the database

func NewTimestamp

func NewTimestamp(t time.Time) Timestamp

func (*Timestamp) FromDB

func (ts *Timestamp) FromDB(data []byte) error

func (*Timestamp) Scan

func (ts *Timestamp) Scan(src any) error

func (*Timestamp) ToDB

func (ts *Timestamp) ToDB() ([]byte, error)

func (*Timestamp) Value

func (ts *Timestamp) Value() (driver.Value, error)

type XormSlog

type XormSlog struct {
	// contains filtered or unexported fields
}

func NewXormSlog

func NewXormSlog(logger *slog.Logger) *XormSlog

func (*XormSlog) Debug

func (l *XormSlog) Debug(v ...any)

func (*XormSlog) Debugf

func (l *XormSlog) Debugf(format string, v ...any)

func (*XormSlog) Error

func (l *XormSlog) Error(v ...any)

func (*XormSlog) Errorf

func (l *XormSlog) Errorf(format string, v ...any)

func (*XormSlog) Info

func (l *XormSlog) Info(v ...any)

func (*XormSlog) Infof

func (l *XormSlog) Infof(format string, v ...any)

func (*XormSlog) IsShowSQL

func (l *XormSlog) IsShowSQL() bool

func (*XormSlog) Level

func (l *XormSlog) Level() log.LogLevel

func (*XormSlog) SetLevel

func (l *XormSlog) SetLevel(level log.LogLevel)

func (*XormSlog) ShowSQL

func (l *XormSlog) ShowSQL(show ...bool)

func (*XormSlog) Warn

func (l *XormSlog) Warn(v ...any)

func (*XormSlog) Warnf

func (l *XormSlog) Warnf(format string, v ...any)

Jump to

Keyboard shortcuts

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