data

package
v0.0.0-...-6b56f1d Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2021 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Database

type Database interface {
	Get() *gorm.DB
	Close() error
	Ping() error
}

Database is the interface to be implemented by all relational databases

type DatabaseConfig

type DatabaseConfig struct {
	*config.ConfigBase
	// contains filtered or unexported fields
}

DatabaseConfig an in-memory object that represents the configuration for all object stores

func NewDatabaseConfig

func NewDatabaseConfig(baseConfig *config.ConfigBase) (*DatabaseConfig, error)

NewDatabaseConfig will reconcile configuration values from the environment and return a complete config object

func (*DatabaseConfig) GetDSN

func (dbConfig *DatabaseConfig) GetDSN() string

GetDSN getter for dataSourceName

func (*DatabaseConfig) GetDatabaseType

func (dbConfig *DatabaseConfig) GetDatabaseType() DatabaseType

GetDatabaseType getter for databaseType

func (*DatabaseConfig) SetDSN

func (dbConfig *DatabaseConfig) SetDSN(dsn string) error

SetDSN setter for dataSourceName

func (*DatabaseConfig) SetDatabaseType

func (dbConfig *DatabaseConfig) SetDatabaseType(databaseType DatabaseType) error

SetDatabaseType setter for databaseType

type DatabaseImpl

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

Database corresponds to a connection to a single database instance

func NewDatabaseImpl

func NewDatabaseImpl(config *DatabaseConfig) (*DatabaseImpl, error)

NewDatabase will return a Database object associated with the provided config, or an error if something went wrong

func (*DatabaseImpl) Close

func (db *DatabaseImpl) Close() error

Close will close the underlying database connection

func (*DatabaseImpl) Get

func (db *DatabaseImpl) Get() *gorm.DB

Get will return the underlying database connection object

func (*DatabaseImpl) Mock

func (db *DatabaseImpl) Mock() sqlmock.Sqlmock

Mock will return the underlying mock expectation object for a mocked database This is used in testing to check expectations

func (*DatabaseImpl) Ping

func (db *DatabaseImpl) Ping() error

Ping will test the underlying database connection

type DatabaseType

type DatabaseType string
const (
	MockDatabase     DatabaseType = "sqlmock"
	PostgresDatabase DatabaseType = "postgres"
)

type TestDatabase

type TestDatabase interface {
	Database
	Mock() sqlmock.Sqlmock
}

TestDatabase is the interface to be implemented by all databases that include mocking functionality

Jump to

Keyboard shortcuts

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