database

package
v0.0.0-...-e249f0d Latest Latest
Warning

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

Go to latest
Published: Mar 23, 2021 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Db *gorm.DB

Db is the database object

View Source
var EsClient *elastic.Client

Functions

func GetESClient

func GetESClient(escfg *EsCfg)

GetESClient Attempts to connect to elastic search using "github.com/olivere/elastic/v7" package. Affect the EsClient to elastic client.

func GetOriginalESClient

func GetOriginalESClient() (*es.Client, error)

GetOriginalESClient Attempts to connect to elastisearch service using "github.com/elastic/go-elasticsearch/v8" package. Return the client and error

func Init

func Init(cfg Config) error

Init Initializes a db connection

func Migrate

func Migrate()

Migrate executes migrations once the db is connected

Types

type Config

type Config struct {
	User     string `env:"DB_USER"`
	Password string `env:"DB_PASSWORD"`
	Port     int    `env:"DB_PORT" envDefault:"5432"`
	Host     string `env:"DB_HOST"`
	Name     string `env:"DB_NAME"`
}

Config is the structure used to load db credentials from the environment.

type EsCfg

type EsCfg struct {
	Url string
}

Jump to

Keyboard shortcuts

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