Documentation
¶
Index ¶
- func Count[T orm.DataModel](h *Hub, data T, qp *dbflex.QueryParam) (int, error)
- func Find[T orm.DataModel](h *Hub, model T, param *dbflex.QueryParam) ([]T, error)
- func FindAnyByCommand[T any](h *Hub, model T, cmd dbflex.ICommand) ([]T, error)
- func FindAnyByFilter[T any](h *Hub, model T, tablename string, filter *dbflex.Filter, n int) ([]T, error)
- func FindAnyByParm[T any](h *Hub, model T, tablename string, qp *dbflex.QueryParam) ([]T, error)
- func FindAnyBySQL[T any](h *Hub, model T, sql string) ([]T, error)
- func FindByCommand[T orm.DataModel](h *Hub, data T, cmd dbflex.ICommand) ([]T, error)
- func FindByFilter[T orm.DataModel](h *Hub, model T, filter *dbflex.Filter) ([]T, error)
- func GeneralDbConnBuilder(txt string) func() (dbflex.IConnection, error)
- func GeneralDbConnBuilderWithTx(txt string, useTx bool) func() (dbflex.IConnection, error)
- func Get[T orm.DataModel](h *Hub, model T) (T, error)
- func GetByFilter[T orm.DataModel](h *Hub, model T, filter *dbflex.Filter) (T, error)
- func GetByID[T orm.DataModel](h *Hub, model T, ids ...interface{}) (T, error)
- func GetByParm[T orm.DataModel](h *Hub, model T, qp *dbflex.QueryParam) (T, error)
- func GetByParmEl[T orm.DataModel](h *Hub, model T, where *dbflex.Filter, order string, fields ...string) (T, error)
- func GetByQuery[T orm.DataModel](h *Hub, model T, queryName string, payload codekit.M) (T, error)
- type Hub
- func (h *Hub) BeginTx() (*Hub, error)
- func (h *Hub) Close()
- func (h *Hub) CloseConnection(idx string, conn dbflex.IConnection)
- func (h *Hub) Commit() error
- func (h *Hub) Count(data orm.DataModel, qp *dbflex.QueryParam) (int, error)
- func (h *Hub) CountAny(name string, qp *dbflex.QueryParam) (int, error)
- func (h *Hub) CountAnyByFilter(name string, f *dbflex.Filter) (int, error)
- func (h *Hub) CountByFilter(data orm.DataModel, f *dbflex.Filter) (int, error)
- func (h *Hub) Delete(data orm.DataModel) error
- func (h *Hub) DeleteAny(name string, filter *dbflex.Filter) error
- func (h *Hub) DeleteByFilter(model orm.DataModel, where *dbflex.Filter) error
- func (h *Hub) DeleteQuery(model orm.DataModel, where *dbflex.Filter) error
- func (h *Hub) EnsureDb(obj orm.DataModel) error
- func (h *Hub) EnsureIndex(tableName, indexName string, unique bool, fields ...string) error
- func (h *Hub) EnsureTable(name string, keys []string, object interface{}) error
- func (h *Hub) Execute(cmd dbflex.ICommand, object interface{}) (interface{}, error)
- func (h *Hub) Get(data orm.DataModel) error
- func (h *Hub) GetAnyByFilter(tableName string, filter *dbflex.Filter, dest interface{}) error
- func (h *Hub) GetAnyByParm(tableName string, parm *dbflex.QueryParam, dest interface{}) error
- func (h *Hub) GetAnyByParmEl(tablename string, dest interface{}, where *dbflex.Filter, order string, ...) error
- func (h *Hub) GetByAttr(data orm.DataModel, attr string, value interface{}) error
- func (h *Hub) GetByFilter(data orm.DataModel, filter *dbflex.Filter) error
- func (h *Hub) GetByID(data orm.DataModel, ids ...interface{}) error
- func (h *Hub) GetByParm(data orm.DataModel, parm *dbflex.QueryParam) error
- func (h *Hub) GetByParmEl(data orm.DataModel, dest interface{}, where *dbflex.Filter, order string, ...) error
- func (h *Hub) GetByQuery(obj orm.DataModel, queryName string, param codekit.M) error
- func (h *Hub) GetClassicConnection() (dbflex.IConnection, error)
- func (h *Hub) GetConnection() (string, dbflex.IConnection, error)
- func (h *Hub) Gets(data orm.DataModel, parm *dbflex.QueryParam, dest interface{}) error
- func (h *Hub) GetsByFilter(data orm.DataModel, filter *dbflex.Filter, dest interface{}) error
- func (h *Hub) GetsByQuery(obj orm.DataModel, queryName string, param codekit.M, target interface{}) error
- func (h *Hub) Insert(data orm.DataModel) error
- func (h *Hub) InsertAny(name string, object interface{}) error
- func (h *Hub) IsTx() bool
- func (h *Hub) Log() *logger.LogEngine
- func (h *Hub) PoolSize() int
- func (h *Hub) Populate(cmd dbflex.ICommand, result interface{}) (int, error)
- func (h *Hub) PopulateByFilter(tableName string, filter *dbflex.Filter, n int, dest interface{}) error
- func (h *Hub) PopulateByParm(tableName string, parm *dbflex.QueryParam, dest interface{}) error
- func (h *Hub) PopulateSQL(sql string, dest interface{}) error
- func (h *Hub) Rollback() error
- func (h *Hub) Save(data orm.DataModel, fields ...string) error
- func (h *Hub) SaveAny(name string, filter *dbflex.Filter, object interface{}) error
- func (h *Hub) SetAutoCloseDuration(d time.Duration) *Hub
- func (h *Hub) SetAutoReleaseDuration(d time.Duration) *Hub
- func (h *Hub) SetLog(l *logger.LogEngine) *Hub
- func (h *Hub) SetOptions(opts *HubOptions) *Hub
- func (h *Hub) SetTimeout(d time.Duration) *Hub
- func (h *Hub) Update(data orm.DataModel, fields ...string) error
- func (h *Hub) UpdateAny(name string, filter *dbflex.Filter, object interface{}, fields ...string) error
- func (h *Hub) UpdateField(data orm.DataModel, where *dbflex.Filter, fields ...string) error
- func (h *Hub) UsePool() bool
- func (h *Hub) Validate() error
- type HubOptions
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FindAnyByCommand ¶ added in v0.3.1
FindAnyByCommand returns all data using dbflex command
func FindAnyByFilter ¶ added in v0.3.1
func FindAnyByParm ¶ added in v0.3.1
func FindAnyBySQL ¶ added in v0.3.1
func FindByCommand ¶ added in v0.3.0
FindByCommand returns all data using dbflex command, generic mode
func FindByFilter ¶ added in v0.3.0
FindByFilter like find but require only filter, generic mode
func GeneralDbConnBuilder ¶ added in v0.1.14
func GeneralDbConnBuilder(txt string) func() (dbflex.IConnection, error)
func GeneralDbConnBuilderWithTx ¶ added in v0.2.7
func GeneralDbConnBuilderWithTx(txt string, useTx bool) func() (dbflex.IConnection, error)
func GetByFilter ¶ added in v0.3.0
GetByFilter return first record by filter
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 NewHubWithOpts ¶ added in v0.1.17
func NewHubWithOpts(fn func() (dbflex.IConnection, error), opts *HubOptions) *Hub
NewHub function to create new hub
func (*Hub) BeginTx ¶ added in v0.1.4
BeginTx create a hub with Transaction. Commit and/or Rollback need to call later on to close the transaction
func (*Hub) CloseConnection ¶
func (h *Hub) CloseConnection(idx string, conn dbflex.IConnection)
CloseConnection to close connection
func (*Hub) CountAny ¶ added in v0.1.17
CountAny returns number of data based on tablename and filter
func (*Hub) CountAnyByFilter ¶ added in v0.2.8
CountByAnyFilter returns number of data based on table name and filter
func (*Hub) CountByFilter ¶ added in v0.2.8
CountByFilter returns number of data based on model and filter
func (*Hub) DeleteAny ¶ added in v0.2.3
DeleteAny delete record on database table. Normally used with no-datamodel object
func (*Hub) DeleteByFilter ¶ added in v0.2.8
DeleteByFilter delete object in database based on specific model and filter
func (*Hub) DeleteQuery ¶
DeleteQuery delete object in database based on specific model and filter, will be DEPRECATED use DeleteByFilter instead
func (*Hub) EnsureIndex ¶ added in v0.2.3
EnsureIndex ensure index existence
func (*Hub) EnsureTable ¶ added in v0.1.7
EnsureTable will ensure existense of table according to given object
func (*Hub) Get ¶
Get return single data based on model. It will find record based on releant ID field
func (*Hub) GetAnyByFilter ¶ added in v0.1.16
GetAnyByFilter returns single data based on filter enteered. Data need to be comply with orm.DataModel.
Because no sort is defined, it will only return 1st row by any given resultset If sort is needed pls use by ByParm
func (*Hub) GetAnyByParm ¶ added in v0.1.16
func (h *Hub) GetAnyByParm(tableName string, parm *dbflex.QueryParam, dest interface{}) error
GetAnyByParm return single data based on filter and table name
func (*Hub) GetAnyByParmEl ¶ added in v0.3.2
func (h *Hub) GetAnyByParmEl(tablename string, dest interface{}, where *dbflex.Filter, order string, fields ...string) error
GetAnyByParmEl return data by parm element
func (*Hub) GetByAttr ¶ added in v0.1.13
GetByAttr returns single data based on value on single field. Data need to be comply with orm.DataModel
func (*Hub) GetByFilter ¶ added in v0.1.15
GetByFilter returns single data based on filter enteered. Data need to be comply with orm.DataModel.
Because no sort is defined, it will only 1st row by any given sort If sort is needed pls use by ByParm
func (*Hub) GetByID ¶
GetByID returns single data based on its ID. Data need to be comply with orm.DataModel
func (*Hub) GetByParmEl ¶ added in v0.3.2
func (h *Hub) GetByParmEl(data orm.DataModel, dest interface{}, where *dbflex.Filter, order string, fields ...string) error
GetByParmEl return data by parm element
func (*Hub) GetByQuery ¶ added in v0.2.4
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() (string, 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) GetsByFilter ¶ added in v0.2.7
GetsByFilter like gets but require only filter
func (*Hub) GetsByQuery ¶ added in v0.2.4
func (*Hub) Populate ¶
Populate will return all data based on command. Normally used with no-datamodel object
func (*Hub) PopulateByFilter ¶ added in v0.1.15
func (h *Hub) PopulateByFilter(tableName string, filter *dbflex.Filter, n int, dest interface{}) error
PopulateByFilter returns all data based on filter and n count. No sort is given, hence it will take n data for resp filter If n-count is 0, it will load all
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
PopulateSQL returns data based on SQL Query
func (*Hub) Save ¶
Save will save data into database, if fields is activated it will save the mentioned fields only, fields will only work with update hence it will assume record already exist
func (*Hub) SaveAny ¶
SaveAny save any object into database table. Normally used with no-datamodel object
func (*Hub) SetAutoCloseDuration ¶
SetAutoCloseDuration set duration for a connection inside Hub Pool to be closed if it is not being used
func (*Hub) SetAutoReleaseDuration ¶
SetAutoReleaseDuration set duration for a connection in pool to be released for a process
func (*Hub) SetOptions ¶ added in v0.2.0
func (h *Hub) SetOptions(opts *HubOptions) *Hub
Set Hub Opts
func (*Hub) UpdateAny ¶ added in v0.1.2
func (h *Hub) UpdateAny(name string, filter *dbflex.Filter, object interface{}, fields ...string) error
UpdateAny update specific fields on database table. Normally used with no-datamodel object
func (*Hub) UpdateField ¶
UpdateField update relevant fields in data based on specific filter