db

package
v0.0.0-...-63a3be0 Latest Latest
Warning

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

Go to latest
Published: Jan 19, 2021 License: GPL-3.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrUnknownDriver database driver unknown
	ErrUnknownDriver = errors.New("database driver unknown")
)

Functions

This section is empty.

Types

type Connection

type Connection struct {
	*gorm.DB
	// contains filtered or unexported fields
}

Connection represents the database Connection with gorm and holds other things like state and logger

func New

func New(driver Driver, dsn string, logger log.Logger) *Connection

New returns a configured Connection object

func (*Connection) Close

func (c *Connection) Close()

Close closing the connection to the database

func (*Connection) Driver

func (c *Connection) Driver() Driver

Driver return Driver that used by database Connection

func (*Connection) Open

func (c *Connection) Open() error

Open opens the connection to the database

func (*Connection) State

func (c *Connection) State() State

State returns state of database Connection

type Driver

type Driver string

Driver defines database Drivers

const (
	// DriverMySQL means that database will use gorm mysql driver
	DriverMySQL Driver = "mysql"
)

func ParseDriver

func ParseDriver(driver string) (Driver, error)

ParseDriver takes a string driver and returns the Driver constant

type State

type State string

State defines the status of the database Connection

const (
	// StateCreated means Connection object is created
	StateCreated State = "created"
	// StateOpening means the Connection object start to connect to the database
	StateOpening State = "opening"
	// StateConnected means the Connection object is connection to the database
	StateConnected State = "connected"
	// StateClosing means the Connection object starts to close the connection to the database
	StateClosing State = "closing"
	// StateClosed means the Connection object is disconnected to the database
	StateClosed State = "closed"
)

func (State) String

func (s State) String() string

Jump to

Keyboard shortcuts

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