databases

package
v1.6.1 Latest Latest
Warning

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

Go to latest
Published: Mar 5, 2025 License: Unlicense Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RequiredCheck added in v1.2.9

func RequiredCheck(t string, data interface{}) (err error)

validate is a func for validate tag from model

Types

type CockroachDB added in v1.2.5

type CockroachDB struct {
	Config Config
}

func (*CockroachDB) Connect added in v1.2.5

func (pgsql *CockroachDB) Connect(cfg *gorm.Config) (DB *gorm.DB, sql_ *sql.DB)

type Config

type Config struct {
	//DATABASE
	HOST string `env:"DB_HOST" envDefault:"localhost" json:"db_host"`
	PORT string `env:"DB_PORT" envDefault:"5432" json:"db_port"`
	NAME string `env:"DB_NAME" json:"db_name"`
	USER string `env:"DB_USER" json:"db_user"`
	PASS string `env:"DB_PASS" json:"db_pass"`
	SSL  string `env:"DB_SSL" envDefault:"disable" json:"db_ssl"`
	TZ   string `env:"TIME_ZONE" envDefault:"Asia/Jakarta" json:"db_tz"`

	MAX_IDLE_CONNS      int `env:"MAX_IDLE_CONNS" json:"max_idle_conns"`           //default 100
	MAX_OPEN_CONNS      int `env:"MAX_OPEN_CONNS" json:"max_open_conns"`           //default 1000
	MAX_IDLE_CONNS_TIME int `env:"MAX_IDLE_CONNS_TIME" json:"max_idle_conns_time"` //default 60m

	//ETC
	EngineName string `env:"ENGINE_NAME" json:"engine_name,omitempty"`

	//Additional GORM CONFIG
	SkipDefaultTransaction bool `env:"SkipDefaultTransaction" envDefault:"false" json:"skip_default_transaction"`
}

Config for databases config

func (*Config) Parse

func (this *Config) Parse() (err error)

Parse for parse env variables to this struct

type PostgreSQL

type PostgreSQL struct {
	Config Config
}

func (*PostgreSQL) Connect

func (pgsql *PostgreSQL) Connect(cfg *gorm.Config, args ...interface{}) (DB *gorm.DB, sql_ *sql.DB)

type SQLite

type SQLite struct {
	Config Config
}

func (*SQLite) Connect

func (sl *SQLite) Connect(cfg *gorm.Config) (DB *gorm.DB, sql_ *sql.DB)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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