Documentation
¶
Index ¶
- type Cond
- type DB
- func (d *DB) AutoCreateTable()
- func (d *DB) CreateTable(v interface{}, opts ...Options) error
- func (d *DB) Database() string
- func (d *DB) Delete(prototype interface{}, args ...interface{}) (sql.Result, error)
- func (d *DB) Insert(v interface{}, opts ...Options) (result sql.Result, err error)
- func (d *DB) InsertFields(s interface{}, backQuoted bool) (keys []string, values []string, err error)
- func (d *DB) InsertIfNotExists(insert interface{}, conds ...interface{}) (res sql.Result, err error)
- func (d *DB) KeepAlive()
- func (d *DB) MustCreateTable(v interface{}, opts ...Options)
- func (d *DB) ReadStructFields(s interface{}) (ret []*Field, err error)
- func (d *DB) ReadTableFields(table string) (ret []*Field, err error)
- func (d *DB) ReadTableIndexes(table string) (map[string]*Index, map[string]*Unique, error)
- func (d *DB) Select(dst interface{}, args ...interface{}) error
- func (d *DB) SelectFields(s interface{}) (string, error)
- func (d *DB) SelectOrInsert(insert interface{}, selectResult interface{}, conds ...interface{}) (res sql.Result, err error)
- func (d *DB) Sqlx() *sqlx.DB
- func (d *DB) StopKeepAlive()
- func (*DB) StructFields(s interface{}) (ret []*Field, err error)
- func (d *DB) Update(prototype interface{}, fields map[string]interface{}, args ...interface{}) (sql.Result, error)
- type Field
- type Index
- type Limit
- type Offset
- type Options
- type Order
- type Param
- type Unique
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DB ¶
type DB struct {
// contains filtered or unexported fields
}
DB is the main structure for mysqlx
func New ¶
New initialize a *DB object with a given *sqlx.DB, which should be connect a certain database.
func (*DB) AutoCreateTable ¶
func (d *DB) AutoCreateTable()
AutoCreateTable enables auto table creation. DB will check if table is created previously before each access to the DB.
Please do NOT invoke this unless you need to automatically create table in runtime.
Note 1: if a table was created once by mysqlx.DB after it was initialized, it will be noted as "created" and cached. Then mysqlx.DB will not check into MySQL DB again.
Note 2: auto-table-creation will NOT be activated in Select() function!
func (*DB) CreateTable ¶
CreateTable creates a table if not exist. If the table exists, it will alter it if necessary
func (*DB) InsertFields ¶
func (d *DB) InsertFields(s interface{}, backQuoted bool) (keys []string, values []string, err error)
InsertFields return keys and values for inserting. Auto-increment fields will be ignored
func (*DB) InsertIfNotExists ¶
func (d *DB) InsertIfNotExists(insert interface{}, conds ...interface{}) (res sql.Result, err error)
InsertIfNotExists is the same as SelectOrInsert but lacking select statement
func (*DB) MustCreateTable ¶
MustCreateTable is same as CreateTable. But is panics if error.
func (*DB) ReadStructFields ¶
ReadStructFields returns all valid SQL fields by given structure and will buffer it
func (*DB) ReadTableFields ¶
ReadTableFields returns all fields in given table
func (*DB) ReadTableIndexes ¶
ReadTableIndexes returns all indexes and uniques of given table name
func (*DB) SelectFields ¶
SelectFields returns all valid SQL fields in given structure
func (*DB) SelectOrInsert ¶
func (d *DB) SelectOrInsert(insert interface{}, selectResult interface{}, conds ...interface{}) (res sql.Result, err error)
SelectOrInsert executes update-if-not-exists statement
func (*DB) StopKeepAlive ¶
func (d *DB) StopKeepAlive()
StopKeepAlive stops the keep-alive operation
func (*DB) StructFields ¶
StructFields is the same as ReadStructFields
type Field ¶
type Field struct {
Name string
Type string
Nullable bool
Default string
Comment string
AutoIncrement bool
// contains filtered or unexported fields
}
Field shows information of a field
func ReadStructFields ¶
ReadStructFields is the same as StructFields
func StructFields ¶
StructFields returns all valid SQL fields by given structure