persistence

package
v0.0.0-...-a03fb21 Latest Latest
Warning

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

Go to latest
Published: Feb 12, 2018 License: Apache-2.0 Imports: 8 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 {
	SqlDB  *sql.DB
	GormDB *gorm.DB
}

DB acts as a handler for databases, providing both Gorm and plain SQL connection interfaces

func NewDB

func NewDB(ds *DataSource) (*DB, error)

Constructor for database handlers, that provide both ORM/SQL connections

func (*DB) ORMConnection

func (db *DB) ORMConnection() (*gorm.DB, error)

GORM connection handler

func (*DB) SQLConnection

func (db *DB) SQLConnection() (*sql.DB, error)

SQL connection handler

type DBUtil

type DBUtil struct {
	*sql.DB
}

Common database utils: create/drop database, etc Acts as a content-aware proxy adapter for sql.DB

func NewDButil

func NewDButil(ds *DataSource) (*DBUtil, error)

func (*DBUtil) CreateDB

func (db *DBUtil) CreateDB(name string) error

Create database with specified name

func (*DBUtil) DropDB

func (db *DBUtil) DropDB(name string) error

Drop database with specified name if it exists

func (*DBUtil) Exists

func (db *DBUtil) Exists(name string) (bool, error)

Checks if database with specific name exists

type DataSource

type DataSource struct {
	Host     string
	Port     int
	Username string
	Password string
	Database string
}

func NewDS

func NewDS(host string, port int, username string, password string, database string) *DataSource

func NewDSFromCFG

func NewDSFromCFG(cfg *config.Config) *DataSource

func (*DataSource) DSN

func (ds *DataSource) DSN() string

func (*DataSource) ShortDSN

func (ds *DataSource) ShortDSN() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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