database

package
v0.0.0-...-5f07eeb Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2020 License: GPL-3.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetDBLogger

func GetDBLogger(file io.Writer, ctx context.Context) logger.Interface

func Setup

func Setup(DBName, Location, User, Password, Port, logPath string)

Setup instantiates DB, opens the DB connection and sets up DB schema.

func Shut

func Shut(DBName, Location, User, Password, Port, logPath string)

Shut closes the input DB connection.

Types

type DBlogger

type DBlogger struct {
	SlowThreshold         time.Duration
	SourceField           string
	SkipErrRecordNotFound bool
}

func NewDBLogger

func NewDBLogger() *DBlogger

func (*DBlogger) Error

func (l *DBlogger) Error(ctx context.Context, s string, args ...interface{})

func (*DBlogger) Info

func (l *DBlogger) Info(ctx context.Context, s string, args ...interface{})

func (*DBlogger) LogMode

func (*DBlogger) Trace

func (l *DBlogger) Trace(ctx context.Context, begin time.Time, fc func() (string, int64), err error)

func (*DBlogger) Warn

func (l *DBlogger) Warn(ctx context.Context, s string, args ...interface{})

type Database

type Database struct {
	Name     string
	Location string
	User     string
	Password string
	Port     string

	Instance *gorm.DB
	// contains filtered or unexported fields
}

Database stores the application data.

func GetWorkingInstance

func GetWorkingInstance() *Database

GetWorkingInstance returns the current working instance of the DB. should be called only after database has been setup

func (*Database) Close

func (database *Database) Close() (err error)

Close closes the DB connection.

func (*Database) MigrateSchema

func (database *Database) MigrateSchema() (err error)

MigrateSchema Migrate DB schema for unit / api integration test code

func (*Database) SetupDBLogger

func (database *Database) SetupDBLogger(logPath string) logger.Interface

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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