database

package
v0.3.21 Latest Latest
Warning

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

Go to latest
Published: Jun 17, 2021 License: GPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RegisterAutoIDAssign

func RegisterAutoIDAssign(db *gorm.DB, generators generators.IDGenerators)

Types

type DBConnection

type DBConnection struct {
	User              string
	Password          string
	Database          string
	Address           string
	Port              int
	Location          string
	Type              string
	Debug             bool
	MaxOpenConnection int
	MaxIdleConnection int
	DB                *gorm.DB
	IDGenerators      generators.IDGenerators
}

func NewConnection

func NewConnection() *DBConnection

func (*DBConnection) AssignGenerators

func (cs *DBConnection) AssignGenerators(idGenerators generators.IDGenerators)

func (*DBConnection) DSN

func (cs *DBConnection) DSN() string

func (*DBConnection) Open

func (cs *DBConnection) Open() (*gorm.DB, error)

func (*DBConnection) ToString

func (cs *DBConnection) ToString() string

type DefaultRepository

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

func (*DefaultRepository) Reader

func (d *DefaultRepository) Reader() *gorm.DB

func (*DefaultRepository) Writer

func (d *DefaultRepository) Writer() *gorm.DB

type Model

type Model struct {
	ID        int64      `gorm:"primary_key" json:"id,string,omitempty"`
	CreatedAt time.Time  `json:"created_at,omitempty"`
	UpdatedAt time.Time  `json:"updated_at,omitempty"`
	DeletedAt *time.Time `sql:"index" json:"deleted_at,omitempty"`
}

type Repository

type Repository interface {
	Reader() *gorm.DB
	Writer() *gorm.DB
}

func New

func New(generators generators.IDGenerators, debug bool) (Repository, error)

func NewRepository

func NewRepository(master *DBConnection, slave *DBConnection) Repository

func NewWithOptions added in v0.3.7

func NewWithOptions(generators generators.IDGenerators, debug bool, max, idle int) (Repository, error)

Jump to

Keyboard shortcuts

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