postgres

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2022 License: MIT Imports: 10 Imported by: 0

README

postgres

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrDBNotDefined ...
	ErrDBNotDefined = errors.New("Database connection is not defined yet")
)

Functions

func ConnectionString

func ConnectionString(conf *Config) string

ConnectionString - Create a connection string

func ConnectionURL

func ConnectionURL(conf *Config) string

ConnectionURL - Create a connection URL

func Migrate

func Migrate(conf *Config, logger *logger.Logger, direction string, version int) error

Migrate ...

Types

type Config

type Config struct {
	Host               string
	Port               int
	DatabaseName       string
	Username           string
	Password           string
	MaxIdleConnections int
	MaxOpenConnections int
	MaxLifetime        int
	MigrationPath      string
}

type Database

type Database interface {
	GetDB() *sqlx.DB
	Select(dest interface{}, query string, args ...interface{}) error
	// Get(dest interface{}, query string, args ...interface{}) error
	Exec(query string, args ...interface{}) (sql.Result, error)
	Query(query string, args ...interface{}) (*sqlx.Rows, error)
	QueryRow(query string, args ...interface{}) *sqlx.Row
	// QueryBind(argCount, rowCount int) string
	// Rebind(query string) string
	Close() error
}

Database is the External Database definition

func NewDatabase

func NewDatabase(conf *Config, logger *logger.Logger) (Database, error)

NewDatabase - Create a new Database

Jump to

Keyboard shortcuts

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