Documentation ¶
Index ¶
- Constants
- func DisableEnv()
- func EnableEnv()
- func EnvKey() string
- func EnvVal() string
- func GetDaoPath() string
- func GetDataSource() map[string]interface{}
- func GetDefaultDataSource() string
- func Init() error
- func SetDecodeFunc(f func(string) (string, error))
- func SetEnvFileName(name string)
- func SetEnvKey(key string)
- func SetEnvVal(val string)
- func SetFileName(name string)
- func SetFormat(f jfile.Format)
- func SetRoot(root string)
- func SubscribeSql(e jevent.Event) jevent.Subscription
- type Agent
- func (a *Agent) Begin() (*sql.Tx, error)
- func (a *Agent) Commit() error
- func (a *Agent) Count(id string, args ...interface{}) (count int, err error)
- func (a *Agent) CountTx(id string, args ...interface{}) (count int, err error)
- func (a *Agent) DB() *sql.DB
- func (a *Agent) DBType() Type
- func (a *Agent) DbName() string
- func (a *Agent) Delete(id string, args ...interface{}) (result Result, err error)
- func (a *Agent) DeletePrepare(id string, param map[string]interface{}, args ...[]interface{}) (result []Result, err error)
- func (a *Agent) DeletePrepareTx(id string, param map[string]interface{}, args ...[]interface{}) (result []Result, err error)
- func (a *Agent) DeleteSqlAndArgs(id string, args ...interface{}) (string, []interface{}, error)
- func (a *Agent) DeleteTx(id string, args ...interface{}) (result Result, err error)
- func (a *Agent) ExecTxWithSql(query string, cond ...interface{}) (Result, error)
- func (a *Agent) ExecWithSql(query string, cond ...interface{}) (Result, error)
- func (a *Agent) Exists(id string, args ...interface{}) (exists bool, err error)
- func (a *Agent) ExistsTx(id string, args ...interface{}) (exists bool, err error)
- func (a *Agent) Insert(id string, args ...interface{}) (result Result, err error)
- func (a *Agent) InsertPrepare(id string, param map[string]interface{}, args ...[]interface{}) (result []Result, err error)
- func (a *Agent) InsertPrepareTx(id string, param map[string]interface{}, args ...[]interface{}) (result []Result, err error)
- func (a *Agent) InsertSqlAndArgs(id string, args ...interface{}) (string, []interface{}, error)
- func (a *Agent) InsertTx(id string, args ...interface{}) (result Result, err error)
- func (a *Agent) InsertTxWithLastInsertId(id string, args ...interface{}) (lastInsertId int, err error)
- func (a *Agent) InsertWithLastInsertId(id string, args ...interface{}) (lastInsertId int, err error)
- func (a *Agent) Other(id string, args ...interface{}) (result Result, err error)
- func (a *Agent) OtherPrepare(id string, param map[string]interface{}, args ...[]interface{}) (result []Result, err error)
- func (a *Agent) OtherPrepareTx(id string, param map[string]interface{}, args ...[]interface{}) (result []Result, err error)
- func (a *Agent) OtherSqlAndArgs(id string, args ...interface{}) (string, []interface{}, error)
- func (a *Agent) OtherTx(id string, args ...interface{}) (result Result, err error)
- func (a *Agent) Ping() error
- func (a *Agent) Query(id string, args ...interface{}) (result Result, err error)
- func (a *Agent) QueryPage(id string, start, end int64, args ...interface{}) (Result, error)
- func (a *Agent) QueryPageTx(id string, start, end int64, args ...interface{}) (Result, error)
- func (a *Agent) QueryPageTxWithSql(query, order string, start, end int64, args ...interface{}) (Result, error)
- func (a *Agent) QueryPageWithSql(query, order string, start, end int64, args ...interface{}) (Result, error)
- func (a *Agent) QueryPrepare(id string, param map[string]interface{}, args ...[]interface{}) (result []Result, err error)
- func (a *Agent) QueryPrepareTx(id string, param map[string]interface{}, args ...[]interface{}) (result []Result, err error)
- func (a *Agent) QueryRow(id string, args ...interface{}) (result Result, err error)
- func (a *Agent) QueryRowPrepare(id string, param map[string]interface{}, args ...[]interface{}) (result []Result, err error)
- func (a *Agent) QueryRowPrepareTx(id string, param map[string]interface{}, args ...[]interface{}) (result []Result, err error)
- func (a *Agent) QueryRowTx(id string, args ...interface{}) (result Result, err error)
- func (a *Agent) QueryRowTxWithSql(query string, cond ...interface{}) (Result, error)
- func (a *Agent) QueryRowWithSql(query string, cond ...interface{}) (Result, error)
- func (a *Agent) QuerySqlAndArgs(id string, args ...interface{}) (string, []interface{}, error)
- func (a *Agent) QueryTx(id string, args ...interface{}) (result Result, err error)
- func (a *Agent) QueryTxWithSql(query string, cond ...interface{}) (Result, error)
- func (a *Agent) QueryWithSql(query string, cond ...interface{}) (Result, error)
- func (a *Agent) Rollback() error
- func (a *Agent) TableSchema(table string, args ...interface{}) ([]TableSchema, error)
- func (a *Agent) TableSchemaTx(table string, args ...interface{}) ([]TableSchema, error)
- func (a *Agent) Tables(args ...interface{}) ([]string, error)
- func (a *Agent) TablesTx(args ...interface{}) ([]string, error)
- func (a *Agent) Tx() *sql.Tx
- func (a *Agent) Update(id string, args ...interface{}) (result Result, err error)
- func (a *Agent) UpdatePrepare(id string, param map[string]interface{}, args ...[]interface{}) (result []Result, err error)
- func (a *Agent) UpdatePrepareTx(id string, param map[string]interface{}, args ...[]interface{}) (result []Result, err error)
- func (a *Agent) UpdateSqlAndArgs(id string, args ...interface{}) (string, []interface{}, error)
- func (a *Agent) UpdateTx(id string, args ...interface{}) (result Result, err error)
- func (a *Agent) UseTx(f func() error) error
- type Logic
- type Operations
- type Operators
- type Param
- type Result
- type TableAgent
- func (ta *TableAgent) AddColumn(args ...interface{}) error
- func (ta *TableAgent) AddMap(m map[string]interface{})
- func (ta *TableAgent) AddParam(param *Param)
- func (ta *TableAgent) Between(col string, val []interface{})
- func (ta *TableAgent) Count() (int, error)
- func (ta *TableAgent) CountTx() (int, error)
- func (ta *TableAgent) Delete() (Result, error)
- func (ta *TableAgent) DeleteTx() (Result, error)
- func (ta *TableAgent) Drop() (Result, error)
- func (ta *TableAgent) DropTx() (Result, error)
- func (ta *TableAgent) ELike(col string, val string)
- func (ta *TableAgent) Equal(col string, val interface{})
- func (ta *TableAgent) Exists() (bool, error)
- func (ta *TableAgent) ExistsTx() (bool, error)
- func (ta *TableAgent) Greater(col string, val interface{})
- func (ta *TableAgent) GreaterThanOrEqual(col string, val interface{})
- func (ta *TableAgent) In(col string, val []interface{})
- func (ta *TableAgent) Insert() (Result, error)
- func (ta *TableAgent) InsertTx() (Result, error)
- func (ta *TableAgent) InsertTxWithLastInsertId() (int, error)
- func (ta *TableAgent) InsertWithLastInsertId() (int, error)
- func (ta *TableAgent) IsNotNull(col string)
- func (ta *TableAgent) IsNull(col string)
- func (ta *TableAgent) Less(col string, val interface{})
- func (ta *TableAgent) LessThanOrEqual(col string, val interface{})
- func (ta *TableAgent) Like(col string, val string)
- func (ta *TableAgent) NotBetween(col string, val []interface{})
- func (ta *TableAgent) NotEqual(col string, val interface{})
- func (ta *TableAgent) NotIn(col string, val []interface{})
- func (ta *TableAgent) Query(v ...interface{}) (Result, error)
- func (ta *TableAgent) QueryPage(start, end int64, v ...interface{}) (Result, error)
- func (ta *TableAgent) QueryPageTx(start, end int64, v ...interface{}) (Result, error)
- func (ta *TableAgent) QueryRow(v ...interface{}) (Result, error)
- func (ta *TableAgent) QueryRowTx(v ...interface{}) (Result, error)
- func (ta *TableAgent) QueryTx(v ...interface{}) (Result, error)
- func (ta *TableAgent) SLike(col string, val string)
- func (ta *TableAgent) SetMap(m map[string]interface{})
- func (ta *TableAgent) SetParams(p []*Param)
- func (ta *TableAgent) Update() (Result, error)
- func (ta *TableAgent) UpdateTx() (Result, error)
- type TableSchema
- type Type
Constants ¶
const (
Unknown = -1
)
Variables ¶
This section is empty.
Functions ¶
func GetDataSource ¶ added in v1.2.2
func GetDataSource() map[string]interface{}
GetDataSource returns json data source
func GetDefaultDataSource ¶
func GetDefaultDataSource() string
GetDefaultDataSource returns json default data source
func SetDecodeFunc ¶
SetDecodeFunc set decode data source name or data source json string function
func SubscribeSql ¶ added in v1.1.1
func SubscribeSql(e jevent.Event) jevent.Subscription
SubscribeSql subscribe sql event
Types ¶
type Agent ¶
type Agent struct {
// contains filtered or unexported fields
}
func GetAgent ¶
GetAgent returns SqlAgent if not input data source key then return default data source agent
func (*Agent) DeletePrepare ¶
func (a *Agent) DeletePrepare(id string, param map[string]interface{}, args ...[]interface{}) (result []Result, err error)
DeletePrepare creates a prepared statement for later queries or executions
func (*Agent) DeletePrepareTx ¶
func (a *Agent) DeletePrepareTx(id string, param map[string]interface{}, args ...[]interface{}) (result []Result, err error)
DeletePrepareTx creates a prepared statement for later queries or executions
func (*Agent) DeleteSqlAndArgs ¶ added in v1.3.16
DeleteSqlAndArgs returns delete sql and args
func (*Agent) ExecTxWithSql ¶
ExecTxWithSql executes a query with tx.Exec
func (*Agent) ExecWithSql ¶
ExecWithSql executes a query with db.Exec
func (*Agent) InsertPrepare ¶
func (a *Agent) InsertPrepare(id string, param map[string]interface{}, args ...[]interface{}) (result []Result, err error)
InsertPrepare creates a prepared statement for later queries or executions
func (*Agent) InsertPrepareTx ¶
func (a *Agent) InsertPrepareTx(id string, param map[string]interface{}, args ...[]interface{}) (result []Result, err error)
InsertPrepareTx creates a prepared statement for later queries or executions
func (*Agent) InsertSqlAndArgs ¶ added in v1.3.16
InsertSqlAndArgs returns insert sql and args
func (*Agent) InsertTxWithLastInsertId ¶ added in v1.3.16
func (a *Agent) InsertTxWithLastInsertId(id string, args ...interface{}) (lastInsertId int, err error)
InsertTxWithLastInsertId return last insert id by QueryRow.Scan
func (*Agent) InsertWithLastInsertId ¶ added in v1.3.16
func (a *Agent) InsertWithLastInsertId(id string, args ...interface{}) (lastInsertId int, err error)
InsertWithLastInsertId return last insert id by QueryRow.Scan
func (*Agent) OtherPrepare ¶
func (a *Agent) OtherPrepare(id string, param map[string]interface{}, args ...[]interface{}) (result []Result, err error)
OtherPrepare creates a prepared statement for later queries or executions
func (*Agent) OtherPrepareTx ¶
func (a *Agent) OtherPrepareTx(id string, param map[string]interface{}, args ...[]interface{}) (result []Result, err error)
OtherPrepareTx creates a prepared statement for later queries or executions
func (*Agent) OtherSqlAndArgs ¶ added in v1.3.16
OtherSqlAndArgs returns other sql and args
func (*Agent) Query ¶
Query executes a query that returns Result the id are for xml select tag id the args are for any placeholder parameters in the query, or result struct point
func (*Agent) QueryPage ¶
QueryPage executes a query that returns Result the id are for xml select tag id the start and end are for query start row and end row the args are for any placeholder parameters in the query, or result struct point
func (*Agent) QueryPageTx ¶
QueryPageTx executes a query that returns Result the id are for xml select tag id the start and end are for query start row and end row the args are for any placeholder parameters in the query, or result struct point
func (*Agent) QueryPageTxWithSql ¶
func (a *Agent) QueryPageTxWithSql(query, order string, start, end int64, args ...interface{}) (Result, error)
QueryPageTxWithSql executes a query that returns Result the start and end are for query start row and end row
func (*Agent) QueryPageWithSql ¶
func (a *Agent) QueryPageWithSql(query, order string, start, end int64, args ...interface{}) (Result, error)
QueryPageWithSql executes a query that returns Result the start and end are for query start row and end row
func (*Agent) QueryPrepare ¶
func (a *Agent) QueryPrepare(id string, param map[string]interface{}, args ...[]interface{}) (result []Result, err error)
QueryPrepare creates a prepared statement for later queries or executions
func (*Agent) QueryPrepareTx ¶
func (a *Agent) QueryPrepareTx(id string, param map[string]interface{}, args ...[]interface{}) (result []Result, err error)
QueryPrepareTx creates a prepared statement for later queries or executions
func (*Agent) QueryRow ¶
QueryRow executes a query that is expected to return at most one row the id are for xml select tag id the args are for any placeholder parameters in the query, or result struct point
func (*Agent) QueryRowPrepare ¶
func (a *Agent) QueryRowPrepare(id string, param map[string]interface{}, args ...[]interface{}) (result []Result, err error)
QueryRowPrepare creates a prepared statement for later queries or executions
func (*Agent) QueryRowPrepareTx ¶
func (a *Agent) QueryRowPrepareTx(id string, param map[string]interface{}, args ...[]interface{}) (result []Result, err error)
QueryRowPrepareTx creates a prepared statement for later queries or executions
func (*Agent) QueryRowTx ¶
QueryRowTx executes a query that is expected to return at most one row the id are for xml select tag id the args are for any placeholder parameters in the query, or result struct point
func (*Agent) QueryRowTxWithSql ¶
QueryRowTxWithSql executes a query that is expected to return at most one row
func (*Agent) QueryRowWithSql ¶
QueryRowWithSql executes a query that is expected to return at most one row
func (*Agent) QuerySqlAndArgs ¶ added in v1.3.16
QuerySqlAndArgs returns query sql and args
func (*Agent) QueryTx ¶
QueryTx executes a query that returns Result the id are for xml select tag id the args are for any placeholder parameters in the query, or result struct point
func (*Agent) QueryTxWithSql ¶
QueryTxWithSql executes a query that returns Result
func (*Agent) QueryWithSql ¶
QueryWithSql executes a query that returns Result
func (*Agent) TableSchema ¶ added in v1.2.2
func (a *Agent) TableSchema(table string, args ...interface{}) ([]TableSchema, error)
TableSchema return table schema or you can use args input query statement
func (*Agent) TableSchemaTx ¶ added in v1.2.2
func (a *Agent) TableSchemaTx(table string, args ...interface{}) ([]TableSchema, error)
TableSchemaTx return table schema or you can use args input query statement
func (*Agent) Tables ¶ added in v1.2.2
Tables returns table name list or you can use args input query statement
func (*Agent) TablesTx ¶ added in v1.2.2
TablesTx returns table name list or you can use args input query statement
func (*Agent) UpdatePrepare ¶
func (a *Agent) UpdatePrepare(id string, param map[string]interface{}, args ...[]interface{}) (result []Result, err error)
UpdatePrepare creates a prepared statement for later queries or executions
func (*Agent) UpdatePrepareTx ¶
func (a *Agent) UpdatePrepareTx(id string, param map[string]interface{}, args ...[]interface{}) (result []Result, err error)
UpdatePrepareTx creates a prepared statement for later queries or executions
func (*Agent) UpdateSqlAndArgs ¶ added in v1.3.16
UpdateSqlAndArgs returns update sql and args
type Operations ¶
type Operations int
Operations sql operations
const ( Select Operations = iota Insert Update Delete Other )
type Operators ¶
type Operators int
Operators clause Operators
func ParseOperators ¶
ParseOperators takes a string Operators and returns the Operators constant.
type Param ¶
type Result ¶
type Result interface { // Row returns query row data // if multiple row then return first row data Row() map[string]interface{} // Rows returns query rows data Rows() []map[string]interface{} // RowStart returns the integer by query page start row number // if not query page, the value default zero RowStart() int64 // RowEnd returns the integer by query page end row number // if not query page, the value default zero RowEnd() int64 // TotalRecord returns query page total record // the other query then returns rows length TotalRecord() int64 // LastInsertId returns the integer generated by the database // in response to a command. Typically this will be from an // "auto increment" column when inserting a new row. Not all // databases support this feature, and the syntax of such // statements varies. LastInsertId() (int64, error) // RowsAffected returns the number of rows affected by an // update, insert, or delete. Not every database or database // driver may support this. RowsAffected() (int64, error) }
type TableAgent ¶
type TableAgent struct { Agent *Agent DSKey string Table string SelStr string OrdStr string Col map[string]interface{} Params []*Param }
func (*TableAgent) AddColumn ¶
func (ta *TableAgent) AddColumn(args ...interface{}) error
AddColumn add insert or update column data
func (*TableAgent) AddMap ¶
func (ta *TableAgent) AddMap(m map[string]interface{})
AddMap add insert or update column data with map[string]interface{}
func (*TableAgent) AddParam ¶
func (ta *TableAgent) AddParam(param *Param)
AddParam add select or update or delete where clause param
func (*TableAgent) Between ¶
func (ta *TableAgent) Between(col string, val []interface{})
Between add And Between Param
func (*TableAgent) Count ¶ added in v1.3.18
func (ta *TableAgent) Count() (int, error)
Count return query count
func (*TableAgent) CountTx ¶ added in v1.3.18
func (ta *TableAgent) CountTx() (int, error)
CountTx return query count
func (*TableAgent) Delete ¶
func (ta *TableAgent) Delete() (Result, error)
Delete executes a query with db.Exec
func (*TableAgent) DeleteTx ¶
func (ta *TableAgent) DeleteTx() (Result, error)
DeleteTx executes a query with tx.Exec
func (*TableAgent) Drop ¶
func (ta *TableAgent) Drop() (Result, error)
Drop executes a query with db.Exec
func (*TableAgent) DropTx ¶
func (ta *TableAgent) DropTx() (Result, error)
DropTx executes a query with tx.Exec
func (*TableAgent) ELike ¶
func (ta *TableAgent) ELike(col string, val string)
ELike add And ELike Param
func (*TableAgent) Equal ¶
func (ta *TableAgent) Equal(col string, val interface{})
Equal add And Equal Param
func (*TableAgent) Exists ¶ added in v1.3.18
func (ta *TableAgent) Exists() (bool, error)
Exists return query sql exists data
func (*TableAgent) ExistsTx ¶ added in v1.3.18
func (ta *TableAgent) ExistsTx() (bool, error)
ExistsTx return query sql exists data
func (*TableAgent) Greater ¶
func (ta *TableAgent) Greater(col string, val interface{})
Greater add And Greater Param
func (*TableAgent) GreaterThanOrEqual ¶
func (ta *TableAgent) GreaterThanOrEqual(col string, val interface{})
GreaterThanOrEqual add And GreaterThanOrEqual Param
func (*TableAgent) Insert ¶
func (ta *TableAgent) Insert() (Result, error)
Insert executes a query with db.Exec
func (*TableAgent) InsertTx ¶
func (ta *TableAgent) InsertTx() (Result, error)
InsertTx executes a query with tx.Exec
func (*TableAgent) InsertTxWithLastInsertId ¶ added in v1.3.18
func (ta *TableAgent) InsertTxWithLastInsertId() (int, error)
InsertTxWithLastInsertId return last insert id by QueryRow.Scan
func (*TableAgent) InsertWithLastInsertId ¶ added in v1.3.18
func (ta *TableAgent) InsertWithLastInsertId() (int, error)
InsertWithLastInsertId return last insert id by QueryRow.Scan
func (*TableAgent) IsNotNull ¶
func (ta *TableAgent) IsNotNull(col string)
IsNotNull add And IsNotNull Param
func (*TableAgent) Less ¶
func (ta *TableAgent) Less(col string, val interface{})
Less add And Less Param
func (*TableAgent) LessThanOrEqual ¶
func (ta *TableAgent) LessThanOrEqual(col string, val interface{})
LessThanOrEqual add And LessThanOrEqual Param
func (*TableAgent) Like ¶
func (ta *TableAgent) Like(col string, val string)
Like add And Like Param
func (*TableAgent) NotBetween ¶
func (ta *TableAgent) NotBetween(col string, val []interface{})
NotBetween add And NotBetween Param
func (*TableAgent) NotEqual ¶
func (ta *TableAgent) NotEqual(col string, val interface{})
NotEqual add And NotEqual Param
func (*TableAgent) NotIn ¶
func (ta *TableAgent) NotIn(col string, val []interface{})
NotIn add And NotIn Param
func (*TableAgent) Query ¶
func (ta *TableAgent) Query(v ...interface{}) (Result, error)
Query executes a query that returns Result
func (*TableAgent) QueryPage ¶
func (ta *TableAgent) QueryPage(start, end int64, v ...interface{}) (Result, error)
QueryPage executes a query that returns Result the start and end are for query start row and end row
func (*TableAgent) QueryPageTx ¶
func (ta *TableAgent) QueryPageTx(start, end int64, v ...interface{}) (Result, error)
QueryPageTx executes a query that returns Result the start and end are for query start row and end row
func (*TableAgent) QueryRow ¶
func (ta *TableAgent) QueryRow(v ...interface{}) (Result, error)
QueryRow executes a query that is expected to return at most one row
func (*TableAgent) QueryRowTx ¶
func (ta *TableAgent) QueryRowTx(v ...interface{}) (Result, error)
QueryRowTx executes a query that is expected to return at most one row
func (*TableAgent) QueryTx ¶
func (ta *TableAgent) QueryTx(v ...interface{}) (Result, error)
QueryTx executes a query that returns Result
func (*TableAgent) SLike ¶
func (ta *TableAgent) SLike(col string, val string)
SLike add And SLike Param
func (*TableAgent) SetMap ¶
func (ta *TableAgent) SetMap(m map[string]interface{})
SetMap set insert or update column data with map[string]interface{}
func (*TableAgent) SetParams ¶
func (ta *TableAgent) SetParams(p []*Param)
SetParams set select or update or delete where clause param
func (*TableAgent) Update ¶
func (ta *TableAgent) Update() (Result, error)
Update executes a query with db.Exec
func (*TableAgent) UpdateTx ¶
func (ta *TableAgent) UpdateTx() (Result, error)
UpdateTx executes a query with tx.Exec
type TableSchema ¶ added in v1.2.2
type TableSchema struct { // ColumnName column name ColumnName string `json:"COLUMN_NAME"` // DataType column data type DataType string `json:"DATA_TYPE"` // IsNullable is null(YES or NO) IsNullable string `json:"IS_NULLABLE"` // DataDefault column default data DataDefault string `json:"DATA_DEFAULT"` // PrimaryKey primary key PrimaryKey interface{} `json:"PRIMARY_KEY"` // IsIdentity is identity(YES OR NO) IsIdentity string `json:"IS_IDENTITY"` // ColumnComment column comment ColumnComment string `json:"COLUMN_COMMENT"` // TableComment table comment TableComment string `json:"TABLE_COMMENT"` }
TableSchema table schema
type Type ¶
type Type int
Type sql type
func ParseDBType ¶
ParseDBType takes a string db Type and returns the db Type constant.