orm

package
v1.1.15 Latest Latest
Warning

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

Go to latest
Published: Jul 26, 2024 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DriverMysql      driver = "mysql"
	DriverTiDB       driver = "tidb"
	DriverPostgres   driver = "postgres"
	DriverSqlite     driver = sqlite.DriverName
	DriverSqlserver  driver = "sqlserver"
	DriverClickhouse driver = "clickhouse"
)
View Source
const (
	DialectMysql      dialect = "mysql"
	DialectPostgres   dialect = "pgx" // or pgx/v5
	DialectOpenGauss  dialect = "opengauss"
	DialectSqlite     dialect = sqlite.DriverName
	DialectSqlserver  dialect = "sqlserver" // or mssql
	DialectClickhouse dialect = "clickhouse"
)

Variables

This section is empty.

Functions

func WithLogger

func WithLogger(l logger.Interface) utils.OptionFunc[newOption]

Types

type DB

type DB struct {
	*gorm.DB
	// contains filtered or unexported fields
}

func (*DB) GetDialector

func (d *DB) GetDialector() gorm.Dialector

func (*DB) GetProxy

func (d *DB) GetProxy() *gorm.DB

func (*DB) WithContext

func (d *DB) WithContext(ctx context.Context) *DB

type Dialect

type Dialect interface {
	New(ctx context.Context, option Option, opts ...utils.OptionExtender) (db *DB, err error)
}
var Gorm Dialect = new(gormDriver)

type Option

type Option struct {
	Driver          driver  `yaml:"driver" json:"driver" toml:"driver"`
	Dialect         dialect `yaml:"dialect" json:"dialect" toml:"dialect"`
	DB              string  `yaml:"db" json:"db" toml:"db"`
	Host            string  `yaml:"host" json:"host" toml:"host"`
	Port            uint    `yaml:"port" json:"port" toml:"port"`
	User            string  `yaml:"user" json:"user" toml:"user"`
	Password        string  `yaml:"password" json:"password" toml:"password" encrypted:""`
	Timeout         string  `yaml:"timeout" json:"timeout" toml:"timeout" default:"5s"`
	ReadTimeout     string  `yaml:"read_timeout" json:"read_timeout" toml:"read_timeout" default:"2s"`
	WriteTimeout    string  `yaml:"write_timeout" json:"write_timeout" toml:"write_timeout" default:"2s"`
	MaxIdleConns    int     `yaml:"max_idle_conns" json:"max_idle_conns" toml:"max_idle_conns" default:"20"`
	MaxOpenConns    int     `yaml:"max_open_conns" json:"max_open_conns" toml:"max_open_conns" default:"20"`
	ConnMaxLifeTime string  `yaml:"conn_max_life_time" json:"conn_max_life_time" toml:"conn_max_life_time" default:"30m"`
	ConnMaxIdleTime string  `yaml:"conn_max_idle_time" json:"conn_max_idle_time" toml:"conn_max_idle_time" default:"15m"`
}

Option db option nolint: revive // struct tag too long issue

Directories

Path Synopsis
Package sqlite fork from github.com/glebarez/sqlite@v1.11.0
Package sqlite fork from github.com/glebarez/sqlite@v1.11.0

Jump to

Keyboard shortcuts

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