escondb

package module
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: May 9, 2022 License: GPL-3.0 Imports: 9 Imported by: 0

README

escondb

Easy Connect To Database Library With Go Language

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DeleteSQL

func DeleteSQL(txtTable string, txtWhere string) string

DeleteSQL is automatic build delete sql

func InsertSQL

func InsertSQL(txtTable string, jsoData *jsons.JSONObject) string

InsertSQL is automatic build insert sql

func Quote

func Quote(str string) string

Quote is add quota in sql in string

func SelectSQL

func SelectSQL(txtTable string, txtColumn string, txtWhere string, txtSort string, intOffset int, intLimit int) string

SelectSQL is automatic build select sql

func UpdateSQL

func UpdateSQL(txtTable string, jsoData *jsons.JSONObject, txtWhere string) string

UpdateSQL is automatic build update sql

Types

type EsconCX added in v0.1.2

type EsconCX interface {
	ORM(txtPrimaryKeyName string, txtForeignKeyPrefix string) *EsconORM
	Query(txtSQL string) (*jsons.JSONArray, error)
	Exec(txtSQL string) (*jsons.JSONObject, error)
	Fetch(txtSQL string) (*jsons.JSONObject, error)
	Exist(txtSQL string) (bool, error)
	SelectRow(txtTable string, txtColumn string, txtWhere string, txtSort string, intOffset int, intLimit int) (*jsons.JSONArray, error)
	InsertRow(txtTable string, jsoData *jsons.JSONObject) (*jsons.JSONObject, error)
	UpdateRow(txtTable string, jsoData *jsons.JSONObject, txtWhere string) (*jsons.JSONObject, error)
	DeleteRow(txtTable string, txtWhere string) (*jsons.JSONObject, error)
	FetchRow(txtTable string, txtColumn string, txtWhere string) (*jsons.JSONObject, error)
	ExistRow(txtTable string, txtWhere string) (bool, error)
	CountRow(txtTable string, txtWhere string) (int, error)
}

EsconCX is interface of DB and TX

type EsconDB added in v0.1.2

type EsconDB struct {
	DB *sql.DB

	Type     string
	Host     string
	Port     int
	Username string
	Password string
	Database string
}

EsconDB is connection object

func Connect

func Connect(txtType string, txtHost string, intPort int, txtUsername string, txtPassword string, txtDBName string) (*EsconDB, error)

Connect is create ESConDB object

func (*EsconDB) Begin added in v0.1.2

func (me *EsconDB) Begin() (*EsconTX, error)

Begin is create tx object

func (*EsconDB) Close added in v0.1.2

func (me *EsconDB) Close() error

Close is close connection

func (*EsconDB) CountRow added in v0.1.2

func (me *EsconDB) CountRow(txtTable string, txtWhere string) (int, error)

CountRow is count all row in database by condition

func (*EsconDB) DeleteRow added in v0.1.2

func (me *EsconDB) DeleteRow(txtTable string, txtWhere string) (*jsons.JSONObject, error)

DeleteRow is delete data in database

func (*EsconDB) Exec added in v0.1.2

func (me *EsconDB) Exec(txtSQL string) (*jsons.JSONObject, error)

Exec is run single sql and return effect number data

func (*EsconDB) Exist added in v0.1.2

func (me *EsconDB) Exist(txtSQL string) (bool, error)

Exist is query check have any one row

func (*EsconDB) ExistRow added in v0.1.2

func (me *EsconDB) ExistRow(txtTable string, txtWhere string) (bool, error)

ExistRow is check data row from database

func (*EsconDB) Fetch added in v0.1.2

func (me *EsconDB) Fetch(txtSQL string) (*jsons.JSONObject, error)

Fetch is run single sql and return first data row

func (*EsconDB) FetchRow added in v0.1.2

func (me *EsconDB) FetchRow(txtTable string, txtColumn string, txtWhere string) (*jsons.JSONObject, error)

FetchRow is get first select data row from database

func (*EsconDB) InsertRow added in v0.1.2

func (me *EsconDB) InsertRow(txtTable string, jsoData *jsons.JSONObject) (*jsons.JSONObject, error)

InsertRow is insert data data to database

func (*EsconDB) ORM added in v0.1.2

func (me *EsconDB) ORM(txtPrimaryKeyName string, txtForeignKeyPrefix string) *EsconORM

ORM is create object relation mapping

func (*EsconDB) Ping added in v0.1.2

func (me *EsconDB) Ping() error

Ping is test connection

func (*EsconDB) Query added in v0.1.2

func (me *EsconDB) Query(txtSQL string) (*jsons.JSONArray, error)

Query is fetch data from query sql

func (*EsconDB) RawDataToJSONObject added in v0.1.2

func (me *EsconDB) RawDataToJSONObject(arrColumns []string, arrColumTypes []*sql.ColumnType, rawDatas []interface{}) *jsons.JSONObject

RawDataToJSONObject is fill data to json object

func (*EsconDB) SelectRow added in v0.1.2

func (me *EsconDB) SelectRow(txtTable string, txtColumn string, txtWhere string, txtSort string, intOffset int, intLimit int) (*jsons.JSONArray, error)

SelectRow is select data row from database

func (*EsconDB) UpdateRow added in v0.1.2

func (me *EsconDB) UpdateRow(txtTable string, jsoData *jsons.JSONObject, txtWhere string) (*jsons.JSONObject, error)

UpdateRow is updata data in database

type EsconORM added in v0.1.2

type EsconORM struct {
	DBX              EsconCX
	PrimaryKeyName   string
	ForeignKeyPrefix string
}

EsconORM is Object relation mapping

func (*EsconORM) Table added in v0.1.2

func (me *EsconORM) Table(txtName string) *EsconORMTable

type EsconORMRow added in v0.1.2

type EsconORMRow struct {
	TABLE   *EsconORMTable
	JSOData *jsons.JSONObject
}

func (*EsconORMRow) Belong added in v0.1.2

func (me *EsconORMRow) Belong(txtLocalKey string, txtRefTable string, txtColumn string) (*EsconORMTable, error)

func (*EsconORMRow) CheckKey added in v0.1.2

func (me *EsconORMRow) CheckKey(txtKey string) bool

func (*EsconORMRow) Child added in v0.1.2

func (me *EsconORMRow) Child(txtRefKey string, txtRefTable string, txtColumn string, txtSort string, intOffset int, intLimit int) (*EsconORMTable, error)

func (*EsconORMRow) Delete added in v0.1.2

func (me *EsconORMRow) Delete(txtKey string) *EsconORMRow

func (*EsconORMRow) FromString added in v0.1.2

func (me *EsconORMRow) FromString(txtJSON string) error

func (*EsconORMRow) GetArray added in v0.1.2

func (me *EsconORMRow) GetArray(txtKey string) *jsons.JSONArray

func (*EsconORMRow) GetBool added in v0.1.2

func (me *EsconORMRow) GetBool(txtKey string) bool

func (*EsconORMRow) GetFloat added in v0.1.2

func (me *EsconORMRow) GetFloat(txtKey string) float64

func (*EsconORMRow) GetInt added in v0.1.2

func (me *EsconORMRow) GetInt(txtKey string) int

func (*EsconORMRow) GetKeys added in v0.1.2

func (me *EsconORMRow) GetKeys(txtKey string) []string

func (*EsconORMRow) GetNull added in v0.1.2

func (me *EsconORMRow) GetNull(txtKey string) interface{}

func (*EsconORMRow) GetObject added in v0.1.2

func (me *EsconORMRow) GetObject(txtKey string) *jsons.JSONObject

func (*EsconORMRow) GetObjectData added in v0.1.2

func (me *EsconORMRow) GetObjectData() *collection.MapKey

func (*EsconORMRow) GetString added in v0.1.2

func (me *EsconORMRow) GetString(txtKey string) string

func (*EsconORMRow) GetType added in v0.1.2

func (me *EsconORMRow) GetType(txtKey string) string

func (*EsconORMRow) HasKey added in v0.1.2

func (me *EsconORMRow) HasKey(txtKey string) bool

func (*EsconORMRow) PutArray added in v0.1.2

func (me *EsconORMRow) PutArray(txtKey string, jsaValue *jsons.JSONArray) *EsconORMRow

func (*EsconORMRow) PutBool added in v0.1.2

func (me *EsconORMRow) PutBool(txtKey string, blnValue bool) *EsconORMRow

func (*EsconORMRow) PutFloat added in v0.1.2

func (me *EsconORMRow) PutFloat(txtKey string, dblValue float64) *EsconORMRow

func (*EsconORMRow) PutInt added in v0.1.2

func (me *EsconORMRow) PutInt(txtKey string, intValue int) *EsconORMRow

func (*EsconORMRow) PutNull added in v0.1.2

func (me *EsconORMRow) PutNull(txtKey string) *EsconORMRow

func (*EsconORMRow) PutObject added in v0.1.2

func (me *EsconORMRow) PutObject(txtKey string, jsoValue *jsons.JSONObject) *EsconORMRow

func (*EsconORMRow) PutString added in v0.1.2

func (me *EsconORMRow) PutString(txtKey string, txtValue string) *EsconORMRow

func (*EsconORMRow) Remove added in v0.1.3

func (me *EsconORMRow) Remove(txtKey string) *EsconORMRow

func (*EsconORMRow) ToJSONObject added in v0.1.4

func (me *EsconORMRow) ToJSONObject() *jsons.JSONObject

func (*EsconORMRow) ToString added in v0.1.2

func (me *EsconORMRow) ToString() string

type EsconORMTable added in v0.1.2

type EsconORMTable struct {
	ORM     *EsconORM
	Name    string
	JSARows *jsons.JSONArray
}

func (*EsconORMTable) Begin added in v0.1.9

func (me *EsconORMTable) Begin()

Iterator support

func (*EsconORMTable) Check added in v0.1.2

func (me *EsconORMTable) Check(txtWhere string) (bool, error)

func (*EsconORMTable) CheckByID added in v0.1.5

func (me *EsconORMTable) CheckByID(varID interface{}) (bool, error)

func (*EsconORMTable) Count added in v0.1.2

func (me *EsconORMTable) Count(txtWhere string) (int, error)

func (*EsconORMTable) Delete added in v0.1.2

func (me *EsconORMTable) Delete(ormRow *EsconORMRow) (*jsons.JSONObject, error)

func (*EsconORMTable) DeleteByID added in v0.1.2

func (me *EsconORMTable) DeleteByID(varID interface{}) (*jsons.JSONObject, error)

func (*EsconORMTable) DeleteByJSON added in v0.1.2

func (me *EsconORMTable) DeleteByJSON(jsoData *jsons.JSONObject) (*jsons.JSONObject, error)

func (*EsconORMTable) Exist added in v0.1.2

func (me *EsconORMTable) Exist(txtWhere string) (bool, error)

func (*EsconORMTable) ExistByID added in v0.1.5

func (me *EsconORMTable) ExistByID(varID interface{}) (bool, error)

func (*EsconORMTable) Fetch added in v0.1.2

func (me *EsconORMTable) Fetch(txtColumn string, txtWhere string) (*EsconORMRow, error)

func (*EsconORMTable) FetchByID added in v0.1.2

func (me *EsconORMTable) FetchByID(txtColumn string, varID interface{}) (*EsconORMRow, error)

func (*EsconORMTable) FetchRow added in v0.1.9

func (me *EsconORMTable) FetchRow() (int, *EsconORMRow)

func (*EsconORMTable) Find added in v0.1.2

func (me *EsconORMTable) Find(txtColumn, txtWhere string, txtSort string, intOffset int, intLimit int) error

func (*EsconORMTable) FindByID added in v0.2.2

func (me *EsconORMTable) FindByID(txtColumn string, varID interface{}) (*EsconORMRow, error)

func (*EsconORMTable) GetRow added in v0.1.2

func (me *EsconORMTable) GetRow(intIndex int) *EsconORMRow

func (*EsconORMTable) Insert added in v0.1.2

func (me *EsconORMTable) Insert(ormRow *EsconORMRow) (*jsons.JSONObject, error)

func (*EsconORMTable) InsertByID added in v0.1.2

func (me *EsconORMTable) InsertByID(varID interface{}, ormRow *EsconORMRow) (*jsons.JSONObject, error)

func (*EsconORMTable) InsertByIDJSON added in v0.1.2

func (me *EsconORMTable) InsertByIDJSON(varID interface{}, jsoData *jsons.JSONObject) (*jsons.JSONObject, error)

func (*EsconORMTable) InsertByJSON added in v0.1.2

func (me *EsconORMTable) InsertByJSON(jsoData *jsons.JSONObject) (*jsons.JSONObject, error)

func (*EsconORMTable) Length added in v0.1.2

func (me *EsconORMTable) Length() int

func (*EsconORMTable) NewRow added in v0.1.2

func (me *EsconORMTable) NewRow(varID interface{}, jsoData *jsons.JSONObject) *EsconORMRow

func (*EsconORMTable) Next added in v0.1.9

func (me *EsconORMTable) Next() bool

func (*EsconORMTable) ToJSONArray added in v0.1.4

func (me *EsconORMTable) ToJSONArray() *jsons.JSONArray

func (*EsconORMTable) ToJSONObject added in v0.1.4

func (me *EsconORMTable) ToJSONObject() *jsons.JSONObject

func (*EsconORMTable) Update added in v0.1.2

func (me *EsconORMTable) Update(ormRow *EsconORMRow) (*jsons.JSONObject, error)

func (*EsconORMTable) UpdateByID added in v0.1.2

func (me *EsconORMTable) UpdateByID(varID interface{}, ormRow *EsconORMRow) (*jsons.JSONObject, error)

func (*EsconORMTable) UpdateByIDJSON added in v0.1.2

func (me *EsconORMTable) UpdateByIDJSON(varID interface{}, jsoData *jsons.JSONObject) (*jsons.JSONObject, error)

func (*EsconORMTable) UpdateByJSON added in v0.1.2

func (me *EsconORMTable) UpdateByJSON(jsoData *jsons.JSONObject) (*jsons.JSONObject, error)

type EsconTX added in v0.1.2

type EsconTX struct {
	DB *EsconDB
	TX *sql.Tx
}

EsconTX is transaction object

func (*EsconTX) Commit added in v0.1.2

func (me *EsconTX) Commit() error

Commit is confirm save data

func (*EsconTX) CountRow added in v0.1.2

func (me *EsconTX) CountRow(txtTable string, txtWhere string) (int, error)

CountRow is count all row in database by condition

func (*EsconTX) DeleteRow added in v0.1.2

func (me *EsconTX) DeleteRow(txtTable string, txtWhere string) (*jsons.JSONObject, error)

DeleteRow is delete data in database

func (*EsconTX) Exec added in v0.1.2

func (me *EsconTX) Exec(txtSQL string) (*jsons.JSONObject, error)

Exec is run single sql and return effect number data

func (*EsconTX) Exist added in v0.1.2

func (me *EsconTX) Exist(txtSQL string) (bool, error)

Exist is query check have any one row

func (*EsconTX) ExistRow added in v0.1.2

func (me *EsconTX) ExistRow(txtTable string, txtWhere string) (bool, error)

ExistRow is check data row from database

func (*EsconTX) Fetch added in v0.1.2

func (me *EsconTX) Fetch(txtSQL string) (*jsons.JSONObject, error)

Fetch is run single sql and return first data row

func (*EsconTX) FetchRow added in v0.1.2

func (me *EsconTX) FetchRow(txtTable string, txtColumn string, txtWhere string) (*jsons.JSONObject, error)

FetchRow is get first select data row from database

func (*EsconTX) InsertRow added in v0.1.2

func (me *EsconTX) InsertRow(txtTable string, jsoData *jsons.JSONObject) (*jsons.JSONObject, error)

InsertRow is insert data data to database

func (*EsconTX) ORM added in v0.1.2

func (me *EsconTX) ORM(txtPrimaryKeyName string, txtForeignKeyPrefix string) *EsconORM

ORM is create object relation mapping

func (*EsconTX) Query added in v0.1.2

func (me *EsconTX) Query(txtSQL string) (*jsons.JSONArray, error)

Query is fetch data from query sql

func (*EsconTX) Rollback added in v0.1.2

func (me *EsconTX) Rollback() error

Rollback is restore data to begin point

func (*EsconTX) SelectRow added in v0.1.2

func (me *EsconTX) SelectRow(txtTable string, txtColumn string, txtWhere string, txtSort string, intOffset int, intLimit int) (*jsons.JSONArray, error)

SelectRow is select data row from database

func (*EsconTX) UpdateRow added in v0.1.2

func (me *EsconTX) UpdateRow(txtTable string, jsoData *jsons.JSONObject, txtWhere string) (*jsons.JSONObject, error)

UpdateRow is updata data in database

Jump to

Keyboard shortcuts

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