postgres

package
v0.14.0 Latest Latest
Warning

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

Go to latest
Published: Jan 29, 2024 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package postgres contains the domain concept definitions needed to support Magistrala PostgreSQL database functionality.

It provides the abstraction of the PostgreSQL database service, which is used to configure, setup and connect to the PostgreSQL database.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Connect

func Connect(cfg Config) (*sqlx.DB, error)

Connect creates a connection to the PostgreSQL instance.

func Setup

func Setup(cfg Config, migrations migrate.MemoryMigrationSource) (*sqlx.DB, error)

Setup creates a connection to the PostgreSQL instance and applies any unapplied database migrations. A non-nil error is returned to indicate failure.

Types

type Config

type Config struct {
	Host        string `env:"HOST"           envDefault:"localhost"`
	Port        string `env:"PORT"           envDefault:"5432"`
	User        string `env:"USER"           envDefault:"magistrala"`
	Pass        string `env:"PASS"           envDefault:"magistrala"`
	Name        string `env:"NAME"           envDefault:""`
	SSLMode     string `env:"SSL_MODE"       envDefault:"disable"`
	SSLCert     string `env:"SSL_CERT"       envDefault:""`
	SSLKey      string `env:"SSL_KEY"        envDefault:""`
	SSLRootCert string `env:"SSL_ROOT_CERT"  envDefault:""`
}

Jump to

Keyboard shortcuts

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