databases

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2022 License: Unlicense Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	//DATABASE
	HOST string `env:"DB_HOST" envDefault:"localhost" json:"db_host"`
	PORT string `env:"DB_PORT" envDefault:"27107" 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"`
}

Config for databases config

func (*Config) Parse

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

Parse for parse env variables to this struct

type Mongo

type Mongo struct {
	Config Config
	Db     *mongo.Database
	Client *mongo.Client
}

func (*Mongo) Collection

func (mdb *Mongo) Collection(col string) (collection *mongo.Collection)

func (*Mongo) Connect

func (mdb *Mongo) Connect() (err error)

type PostgreSQL

type PostgreSQL struct {
	Config Config
}

func (*PostgreSQL) Connect

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

type SQLite added in v0.3.0

type SQLite struct {
	Config Config
}

func (*SQLite) Connect added in v0.3.0

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

Jump to

Keyboard shortcuts

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