database

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2020 License: MIT Imports: 10 Imported by: 13

Documentation

Index

Constants

View Source
const (
	DatabaseFloatingPrecision = 12
)

Variables

View Source
var (
	ErrInvalidDatabase = errors.New("Invalid database")
)

Functions

func OptionArgs

func OptionArgs(args *Options)

Types

type Context added in v0.1.0

type Context interface {
	DB() DB

	Migrate(models []Model) error
	Transaction(txFunc func(tx Context) error) error
}

func New added in v0.1.0

func New(options Options) Context

New create new mysql connection pannic if failed to connect

type DB added in v0.1.0

type DB interface{}

Database (GORM)

type Database

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

func (*Database) DB

func (d *Database) DB() DB

DB returns subsequent db connection see Context interface

func (*Database) Migrate

func (p *Database) Migrate(models []Model) error

func (*Database) Transaction

func (p *Database) Transaction(txFunc func(tx Context) error) error

type Model added in v0.1.0

type Model interface{}

type Options

type Options struct {
	HostName      string
	Port          int
	User          string
	Password      string
	Database      string
	EnableLogging bool
}

func DefaultOptions added in v0.0.3

func DefaultOptions() Options

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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