db

package
v0.0.0-...-5646104 Latest Latest
Warning

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

Go to latest
Published: May 21, 2020 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DB

type DB struct {
	Gorm *gorm.DB
}

TODO: Gorm field is a public property - this is not ISP 👎

func NewDB

func NewDB(config IDBConfig, l *logrus.Logger) (*DB, error)

func (*DB) Close

func (db *DB) Close() error

func (*DB) CreateSession

func (db *DB) CreateSession() *Session

type DBPostgreSQLConfig

type DBPostgreSQLConfig struct {
	Host     string `json:"host,omitempty" env:"DB_HOST" envDefault:"0.0.0.0"`
	Port     int    `json:"port,omitempty" env:"DB_PORT" envDefault:"5432"`
	User     string `json:"user,omitempty" env:"DB_USER" envDefault:"guest"`
	Password string `json:"password,omitempty" env:"DB_PASSWORD" envDefault:""`
	DBName   string `json:"dbname,omitempty" env:"DB_NAME" envDefault:"go-clean"`
}

func NewDBPostgreSQLConfigFromEnv

func NewDBPostgreSQLConfigFromEnv() (*DBPostgreSQLConfig, error)

func (*DBPostgreSQLConfig) ConnectionString

func (c *DBPostgreSQLConfig) ConnectionString() string

func (*DBPostgreSQLConfig) Dialect

func (c *DBPostgreSQLConfig) Dialect() string

func (*DBPostgreSQLConfig) Import

func (c *DBPostgreSQLConfig) Import() error

type DBSQLiteConfig

type DBSQLiteConfig struct {
	Path string `json:"path,omitempty" env:"DB_FILE_PATH"`
}

func NewDBSQLiteConfig

func NewDBSQLiteConfig() (*DBSQLiteConfig, error)

func (*DBSQLiteConfig) ConnectionString

func (c *DBSQLiteConfig) ConnectionString() string

func (*DBSQLiteConfig) Dialect

func (c *DBSQLiteConfig) Dialect() string

func (*DBSQLiteConfig) Import

func (c *DBSQLiteConfig) Import() error

type IDBConfig

type IDBConfig interface {
	Dialect() string
	ConnectionString() string
}

type Session

type Session struct {
	Gorm *gorm.DB
}

TODO: Gorm field is a public property - this is not ISP 👎

func NewSession

func NewSession(gorm *gorm.DB) *Session

func (*Session) BeginTransaction

func (s *Session) BeginTransaction(value interface{}) *Session

func (*Session) DefferWithRollback

func (s *Session) DefferWithRollback()

Jump to

Keyboard shortcuts

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