datahub

package module
v0.1.7 Latest Latest
Warning

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

Go to latest
Published: Jun 20, 2020 License: Apache-2.0 Imports: 7 Imported by: 13

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Hub

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

Hub main datahub object. This object need to be initiated to work with datahub

func NewHub

func NewHub(fn func() (dbflex.IConnection, error), usePool bool, poolsize int) *Hub

NewHub function to create new hub

func (*Hub) BeginTx added in v0.1.4

func (h *Hub) BeginTx() (*Hub, error)

BeginTx create a hub with Transaction. Commit and/or Rollback need to call later on to close the transaction

func (*Hub) Close

func (h *Hub) Close()

func (*Hub) CloseConnection

func (h *Hub) CloseConnection(idx int, conn dbflex.IConnection)

CloseConnection to close connection

func (*Hub) Commit added in v0.1.4

func (h *Hub) Commit() error

Commit commits all change into database

func (*Hub) Count

func (h *Hub) Count(data orm.DataModel, qp *dbflex.QueryParam) (int, error)

Count returns number of data based on model and filter

func (*Hub) Delete

func (h *Hub) Delete(data orm.DataModel) error

Delete delete respective model record on database

func (*Hub) DeleteQuery

func (h *Hub) DeleteQuery(model orm.DataModel, where *dbflex.Filter) error

DeleteQuery delete object in database based on specific model and filter

func (*Hub) EnsureTable added in v0.1.7

func (h *Hub) EnsureTable(name string, keys []string, object interface{}) error

EnsureTable will ensure existense of table according to given object

func (*Hub) Execute

func (h *Hub) Execute(cmd dbflex.ICommand, object interface{}) (interface{}, error)

Execute will execute command. Normally used with no-datamodel object

func (*Hub) Get

func (h *Hub) Get(data orm.DataModel) error

Get return single data based on model. It will find record based on releant ID field

func (*Hub) GetByID

func (h *Hub) GetByID(data orm.DataModel, ids ...interface{}) error

GetByID returns single data based on its ID. Data need to be comply with orm.DataModel

func (*Hub) GetByParm

func (h *Hub) GetByParm(data orm.DataModel, parm *dbflex.QueryParam) error

GetByParm return single data based on filter

func (*Hub) GetClassicConnection

func (h *Hub) GetClassicConnection() (dbflex.IConnection, error)

GetClassicConnection get connection without using pool. CleanUp operation need to be done manually

func (*Hub) GetConnection

func (h *Hub) GetConnection() (int, dbflex.IConnection, error)

GetConnection to generate connection. It will return index, connection and error. Index and connection need to be retain for purpose of closing the connection. It is advised to use other DB operation related of Hub rather than build manual connection

func (*Hub) Gets

func (h *Hub) Gets(data orm.DataModel, parm *dbflex.QueryParam, dest interface{}) error

Gets return all data based on model and filter

func (*Hub) Insert

func (h *Hub) Insert(data orm.DataModel) error

Insert will create data into database

func (*Hub) Log

func (h *Hub) Log() *toolkit.LogEngine

Log get logger object

func (*Hub) PoolSize

func (h *Hub) PoolSize() int

PoolSize returns size of the pool

func (*Hub) Populate

func (h *Hub) Populate(cmd dbflex.ICommand, result interface{}) (int, error)

Populate will return all data based on command. Normally used with no-datamodel object

func (*Hub) PopulateByParm

func (h *Hub) PopulateByParm(tableName string, parm *dbflex.QueryParam, dest interface{}) error

PopulateByParm returns all data based on table name and QueryParm. Normally used with no-datamodel object

func (*Hub) PopulateSQL added in v0.1.3

func (h *Hub) PopulateSQL(sql string, dest interface{}) error

PopulateSQL returns data based on SQL Query

func (*Hub) Rollback added in v0.1.4

func (h *Hub) Rollback() error

Rollback to reverts back all change into database

func (*Hub) Save

func (h *Hub) Save(data orm.DataModel) error

Save will save data into database

func (*Hub) SaveAny

func (h *Hub) SaveAny(name string, object interface{}) error

SaveAny save any object into database table. Normally used with no-datamodel object

func (*Hub) SetAutoCloseDuration

func (h *Hub) SetAutoCloseDuration(d time.Duration) *Hub

SetAutoCloseDuration set duration for a connection inside Hub Pool to be closed if it is not being used

func (*Hub) SetAutoReleaseDuration

func (h *Hub) SetAutoReleaseDuration(d time.Duration) *Hub

SetAutoReleaseDuration set duration for a connection in pool to be released for a process

func (*Hub) SetLog

func (h *Hub) SetLog(l *toolkit.LogEngine) *Hub

SetLog set logger

func (*Hub) Update

func (h *Hub) Update(data orm.DataModel) error

Update will update single data in database based on specific model

func (*Hub) UpdateAny added in v0.1.2

func (h *Hub) UpdateAny(name string, object interface{}, fields ...string) error

UpdateAny update specific fields on database table. Normally used with no-datamodel object Will be deprecated

func (*Hub) UpdateField

func (h *Hub) UpdateField(data orm.DataModel, where *dbflex.Filter, fields ...string) error

UpdateField update relevant fields in data based on specific filter

func (*Hub) UsePool

func (h *Hub) UsePool() bool

UsePool is a hub using pool

Jump to

Keyboard shortcuts

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