db

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2020 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DatabaseUpdateTimeout = time.Second * 5
	DatabaseLoadTimeout   = time.Second * 5
)
View Source
var ErrNoResult = errors.New("db return no result")

db find no result

Functions

This section is empty.

Types

type DB

type DB interface {
	MigrateTable(tblName string, indexNames ...string) error
	SaveObject(tblName string, x DBObjector) error
	SaveFields(tblName string, x DBObjector, fields map[string]interface{}) error
	LoadObject(tblName, key string, value interface{}, x DBObjector) error
	LoadArray(tblName, key string, storeIndex int64, pool *sync.Pool) ([]interface{}, error)
	DeleteObject(tblName string, x DBObjector) error
	Exit()
}

func NewDB

func NewDB(ctx *cli.Context) DB

func NewMongoDB

func NewMongoDB(ctx *cli.Context) DB

type DBObjector

type DBObjector interface {
	GetObjID() int64
	AfterLoad() error
}

DBObjector save and load with all structure

type MongoDB

type MongoDB struct {
	sync.RWMutex
	utils.WaitGroupWrapper
	// contains filtered or unexported fields
}

func (*MongoDB) DeleteObject

func (m *MongoDB) DeleteObject(tblName string, x DBObjector) error

func (*MongoDB) Exit

func (m *MongoDB) Exit()

func (*MongoDB) LoadArray

func (m *MongoDB) LoadArray(tblName string, key string, storeIndex int64, pool *sync.Pool) ([]interface{}, error)

func (*MongoDB) LoadObject

func (m *MongoDB) LoadObject(tblName, key string, value interface{}, x DBObjector) error

func (*MongoDB) MigrateTable

func (m *MongoDB) MigrateTable(name string, indexNames ...string) error

migrate collection

func (*MongoDB) SaveFields

func (m *MongoDB) SaveFields(tblName string, x DBObjector, fields map[string]interface{}) error

func (*MongoDB) SaveObject

func (m *MongoDB) SaveObject(tblName string, x DBObjector) error

Jump to

Keyboard shortcuts

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