db

package
v0.0.0-...-0356a80 Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2020 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultConnectionString = "postgres://%s:%s@localhost:5432/%s?sslmode=disable"

DefaultConnectionString is the default string for formatting

View Source
const DefaultType = "postgres"

DefaultType is the default database type

Variables

This section is empty.

Functions

This section is empty.

Types

type IRepository

type IRepository interface {
	Migrate() error
}

IRepository for all repositories

type Info

type Info struct {
	Name     string
	Type     string
	Username string
	Password string
}

Info represents the connection details

func NewDefaultInfo

func NewDefaultInfo() (*Info, error)

NewDefaultInfo creates database info type

func NewInfo

func NewInfo(name, username, password string) (*Info, error)

NewInfo creates database info type

func (*Info) ConnectionString

func (info *Info) ConnectionString() string

ConnectionString returns the formatted connection string

type Repository

type Repository struct {
	// contains filtered or unexported fields
}

Repository that reprents the access to the underlying database

func NewDefaultRepository

func NewDefaultRepository() (*Repository, error)

NewDefaultRepository returns production database access

func NewRepository

func NewRepository(info *Info) (*Repository, error)

NewRepository returns production database access

func (*Repository) Close

func (r *Repository) Close() error

Close the DB connection

func (*Repository) Create

func (r *Repository) Create(entity interface{}) error

Create the entity in the database

func (*Repository) Migrate

func (r *Repository) Migrate(entities []interface{}) error

Migrate placeholder for service specific migration

func (*Repository) Open

func (r *Repository) Open() error

Open the database and sets the underlying configuration

func (*Repository) Ping

func (r *Repository) Ping() error

Ping pings the underlying database to ensure it's contactable

type Settings

type Settings struct {
	MaxIdle     int
	MaxOpen     int
	MaxLifetime time.Duration
	Attempts    uint
	Delay       time.Duration
}

Settings for the database connection

func NewSettings

func NewSettings(name string) *Settings

NewSettings creates the settings

Jump to

Keyboard shortcuts

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