db

package
v1.10.0 Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2021 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ContainerID defines the id to be used as the container registration id
	// of a db factory instance, and as a base id of all other db
	// package instances registered in the application container.
	ContainerID = rest.ContainerID + ".db"

	// ContainerConfigID container registration id of the config instance.
	ContainerConfigID = config.ContainerID

	// ContainerConnConfigID defines the id to be used as the container
	// registration id of the database connection configuration instance.
	ContainerConnConfigID = ContainerID + ".config"

	// ContainerDialectFactoryID defines the id to be used as the container
	// registration id of the database connection dialect factory instance.
	ContainerDialectFactoryID = ContainerID + ".dialect.factory"

	// ContainerPrimaryID defines the id to be used as the container
	// registration id of primary database instance.
	ContainerPrimaryID = ContainerID + ".primary"
)
View Source
const (
	// Env defines the gapp-rest/db package environment entry id
	// base string.
	Env = rest.Env + "_DB"

	// EnvConfigPath defines the name of the environment variable
	// to be checked for an overriding value for the configuration path
	// that contains the database connection configurations.
	EnvConfigPath = Env + "_CONFIG_PATH"

	// EnvPrimary defines the name of the environment variable
	// to be checked for an overriding value for the primary database.
	EnvPrimary = Env + "_PRIMARY"
)

Variables

View Source
var (
	// ConfigPath contains the configuration path that holds the
	// database connection configurations.
	ConfigPath = "db"

	// Primary contains the name given to the primary connection.
	Primary = "primary"
)

Functions

func ErrNoConfig

func ErrNoConfig(name string) error

ErrNoConfig generates a configuration not found error.

func ErrUnknownDialect

func ErrUnknownDialect(name string) error

ErrUnknownDialect generates an unrecognized dialect in configuration error.

func NewProvider

func NewProvider() gapp.Provider

NewProvider will create a new migration provider instance

Types

type ConnectionFactory

type ConnectionFactory interface {
	Get(name string, cfg *gorm.Config) (*gorm.DB, error)
}

ConnectionFactory defines the interface of a database connection factory.

func NewConnectionFactory

func NewConnectionFactory(dialectFactory DialectFactory) (ConnectionFactory, error)

NewConnectionFactory instantiates a new connection factory instance.

type DialectFactory

type DialectFactory interface {
	Get(name string) (gorm.Dialector, error)
}

DialectFactory defines the interface of a connection dialect factory instance.

func NewDialectFactory

func NewDialectFactory(cfg config.Partial) (DialectFactory, error)

NewDialectFactory instantiates a new connection dialect factory instance.

Jump to

Keyboard shortcuts

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