Documentation
¶
Index ¶
- type ColumnMetadata
- type DataBaseMetadata
- type MysqlAPI
- func (api *MysqlAPI) Connection() *sql.DB
- func (api *MysqlAPI) Create(table string, obj map[string]interface{}) (rs sql.Result, err error)
- func (api *MysqlAPI) CurrentDatabaseName() string
- func (api *MysqlAPI) Delete(table string, id interface{}, obj map[string]interface{}) (rs sql.Result, err error)
- func (api *MysqlAPI) GetConnectionPool(dbURI string) *sql.DB
- func (api *MysqlAPI) GetDatabaseMetadata() *DataBaseMetadata
- func (api *MysqlAPI) SQL() *SQL
- func (api *MysqlAPI) Select(table string, id interface{}, limit int, offset int, fields []interface{}, ...) (rs []map[string]interface{}, err error)
- func (api *MysqlAPI) Stop() *MysqlAPI
- func (api *MysqlAPI) Update(table string, id interface{}, obj map[string]interface{}) (rs sql.Result, err error)
- func (api *MysqlAPI) UpdateAPIMetadata() *MysqlAPI
- type QueryOption
- type SQL
- func (s *SQL) DeleteByTable(tableName string, mWhere map[string]interface{}) (sql string, err error)
- func (s *SQL) DeleteByTableAndId(tableName string, id interface{}) (sql string, err error)
- func (s *SQL) GetByTable(tableName string, opt QueryOption) (sql string, err error)
- func (s *SQL) GetByTableAndID(tableName string, id interface{}, opt QueryOption) (sql string, err error)
- func (s *SQL) InsertByTable(tableName string, record map[string]interface{}) (sql string, err error)
- func (s *SQL) UpdateByTableAndId(tableName string, id interface{}, record map[string]interface{}) (sql string, err error)
- type TableMetadata
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ColumnMetadata ¶
type ColumnMetadata struct { ColumnName string // column name or code ? ColumnType string // column type NullAble string // column null able // If Key is MUL, multiple occurrences of a given value are // permitted within the column. The column is the first column // of a nonunique index or a unique-valued index that can contain // NULL values. Key string // column key type DefaultValue string // default value if have Extra string // extra info, for example, auto_increment }
ColumnMetadata metadata of a column
type DataBaseMetadata ¶
type DataBaseMetadata struct { DatabaseName string // database name Tables []*TableMetadata // collection of tables }
DataBaseMetadata metadata of a database
func (*DataBaseMetadata) GetSimpleMetadata ¶ added in v1.1.0
func (d *DataBaseMetadata) GetSimpleMetadata() (rt map[string]map[string]string)
GetSimpleMetadata
func (*DataBaseMetadata) GetTableMeta ¶
func (d *DataBaseMetadata) GetTableMeta(tableName string) *TableMetadata
GetTableMeta
func (*DataBaseMetadata) HaveTable ¶
func (d *DataBaseMetadata) HaveTable(sTableName string) bool
HaveTable
func (*DataBaseMetadata) TableHaveField ¶
func (d *DataBaseMetadata) TableHaveField(sTableName string, sFieldName string) bool
TableHaveField
type MysqlAPI ¶
type MysqlAPI struct {
// contains filtered or unexported fields
}
MysqlAPI
func NewMysqlAPI ¶
NewMysqlAPI create new MysqlAPI instance
func (*MysqlAPI) CurrentDatabaseName ¶
CurrentDatabaseName return current database
func (*MysqlAPI) Delete ¶
func (api *MysqlAPI) Delete(table string, id interface{}, obj map[string]interface{}) (rs sql.Result, err error)
Delete by table name and where obj
func (*MysqlAPI) GetConnectionPool ¶
GetConnectionPool which Pool is Singleton Connection Pool
func (*MysqlAPI) GetDatabaseMetadata ¶
func (api *MysqlAPI) GetDatabaseMetadata() *DataBaseMetadata
GetDatabaseMetadata return database meta
func (*MysqlAPI) Select ¶
func (api *MysqlAPI) Select(table string, id interface{}, limit int, offset int, fields []interface{}, wheres map[string]goqu.Op, links []interface{}) (rs []map[string]interface{}, err error)
Select by table name , where or id
func (*MysqlAPI) Update ¶
func (api *MysqlAPI) Update(table string, id interface{}, obj map[string]interface{}) (rs sql.Result, err error)
Update by table name and obj map
func (*MysqlAPI) UpdateAPIMetadata ¶ added in v1.1.0
UpdateAPIMetadata use to update the metadata of the MySQLAPI instance
If database tables structure changed, it will be useful
type QueryOption ¶
type QueryOption struct {
// contains filtered or unexported fields
}
QueryConfig for Select method
type SQL ¶
type SQL struct {
// contains filtered or unexported fields
}
SQL return sqls by sql builder
func (*SQL) DeleteByTable ¶
func (s *SQL) DeleteByTable(tableName string, mWhere map[string]interface{}) (sql string, err error)
DeleteByTable by where
func (*SQL) DeleteByTableAndId ¶
DeleteByTableAndId
func (*SQL) GetByTable ¶
func (s *SQL) GetByTable(tableName string, opt QueryOption) (sql string, err error)
GetByTable with filter
func (*SQL) GetByTableAndID ¶
func (s *SQL) GetByTableAndID(tableName string, id interface{}, opt QueryOption) (sql string, err error)
GetByTableAndID for specific record in table
type TableMetadata ¶
type TableMetadata struct { TableName string //table name Columns []*ColumnMetadata //collections of column }
TableMetadata metadata of a table
func (*TableMetadata) GetPrimaryColumn ¶
func (t *TableMetadata) GetPrimaryColumn() *ColumnMetadata
GetPrimaryColumn
func (*TableMetadata) HaveField ¶
func (t *TableMetadata) HaveField(sFieldName string) bool
HaveField