Documentation ¶
Index ¶
- Constants
- Variables
- func Check(err error)
- func IndexN(str string, c byte, n int) int
- func IsDup(err error) bool
- func NewCQLSession(hosts []string, keySpace string) (*gocql.Session, error)
- func NoRows(err error) bool
- func Now() string
- func OpenFile(filePath string) *os.File
- type Col
- type ColFieldMap
- type DB
- func (db *DB) Bind(tableName string, ifc interface{}, enableCache bool)
- func (db *DB) Close() error
- func (db *DB) DebugCache()
- func (db *DB) EnableCache(b bool)
- func (db *DB) ErrorLog(s string, args ...interface{})
- func (db *DB) ErrorSQL(s string, sql1 string, args ...interface{})
- func (db *DB) Exec(sql1 string, args ...interface{}) (n int64, err error)
- func (db *DB) LoadCache()
- func (db *DB) Log(s string, args ...interface{})
- func (db *DB) LogSQL(s string, args ...interface{})
- func (db *DB) Panic(s string, args ...interface{})
- func (db *DB) SetReadOnly(b bool)
- func (db *DB) Table(name string) *Query
- type M
- type Map
- type Query
- func (q *Query) All(arrListIfc interface{}) (err error)
- func (q *Query) AllFromCache() *syncmap.Map
- func (q *Query) And(str string, args ...interface{}) *Query
- func (q *Query) Bind(ifc interface{}, enableCache bool)
- func (q *Query) CQLQuery(sql1 string, args ...interface{}) (rows *gocql.Iter, err error)
- func (q *Query) Count() (n int64, err error)
- func (q *Query) Delete() (n int64, err error)
- func (q *Query) Fields(fields ...string) *Query
- func (q *Query) Insert(ifc interface{}) (insertId int64, err error)
- func (q *Query) InsertIgnore(ifc interface{}) (insertId int64, err error)
- func (q *Query) Limit(limitStart int64, limitEnds ...int64) *Query
- func (q *Query) LoadCache()
- func (q *Query) Max(colName string) (n int64, err error)
- func (q *Query) Min(colName string) (n int64, err error)
- func (q *Query) One(arrIfc interface{}) (err error)
- func (q *Query) Or(str string, args ...interface{}) *Query
- func (q *Query) QueryRowScanX(sql1 string, args ...interface{}) (n int64, err error)
- func (q *Query) Replace(ifc interface{}) (insertId int64, err error)
- func (q *Query) SQLQuery(sql1 string, args ...interface{}) (rows *sql.Rows, err error)
- func (q *Query) Sort(colName string, order int) *Query
- func (q *Query) SortM(m M) *Query
- func (q *Query) Sum(colName string) (n int64, err error)
- func (q *Query) Truncate() (err error)
- func (q *Query) Update(ifc interface{}) (affectedRows int64, err error)
- func (q *Query) UpdateM(m M) (affectedRows int64, err error)
- func (q *Query) Where(str string, args ...interface{}) *Query
- func (q *Query) WhereM(m M) *Query
- func (q *Query) WherePK(args ...interface{}) *Query
- type TableStruct
Constants ¶
View Source
const ( ACTION_SELECT_ONE int = iota ACTION_SELECT_ALL ACTION_UPDATE ACTION_UPDATE_M ACTION_DELETE ACTION_INSERT ACTION_INSERT_IGNORE ACTION_REPLACE ACTION_COUNT ACTION_SUM )
sql action:
View Source
const ( DRIVER_MYSQL int = iota DRIVER_SQLITE DRIVER_CQL )
View Source
const KEY_SEP string = "-"
Variables ¶
View Source
var ErrNoRows = sql.ErrNoRows
Functions ¶
Types ¶
type Col ¶
type Col struct { ColName string // 列名: id FieldName string // 结构体中的名字:Id FieldPos []int // 在结构体中的位置,支持嵌套 [1,0,-1,-1,-1] FieldStruct reflect.StructField }
type ColFieldMap ¶
type ColFieldMap struct {
// contains filtered or unexported fields
}
func NewColFieldMap ¶
func NewColFieldMap() *ColFieldMap
func (*ColFieldMap) Add ¶
func (c *ColFieldMap) Add(col *Col)
func (*ColFieldMap) Exists ¶
func (c *ColFieldMap) Exists(key string) bool
func (*ColFieldMap) GetByColName ¶
func (c *ColFieldMap) GetByColName(colName string) *Col
func (*ColFieldMap) GetByFieldName ¶
func (c *ColFieldMap) GetByFieldName(fieldName string) *Col
type DB ¶
type DB struct { *sql.DB CQLSession *gocql.Session CQLMeta *gocql.KeyspaceMetadata DriverType int DbName string Stdout io.Writer Stderr io.Writer // contains filtered or unexported fields }
func (*DB) DebugCache ¶
func (db *DB) DebugCache()
func (*DB) EnableCache ¶
func (*DB) SetReadOnly ¶
type Query ¶
type Query struct { *DB // contains filtered or unexported fields }
func (*Query) AllFromCache ¶
func (*Query) InsertIgnore ¶
ifc 最好为 &struct
func (*Query) Limit ¶
Limit(10) Limit(0, 10) // Cassandra 不支持 // Cassandra 只能"下一页"的方式进行翻页,默认按照主键排序 SELECT * FROM user WHERE token(uid)>token(300) LIMIT 1; SELECT * FROM user WHERE token(id) > token(xx-xx-xx-xx-xx) AND regdate >= '2019-01-01' LIMIT 10 ALLOW FILTERING;
func (*Query) QueryRowScanX ¶
type TableStruct ¶
type TableStruct struct { ColFieldMap *ColFieldMap PrimaryKey []string PrimaryKeyPos [][]int AutoIncrement string Type reflect.Type EnableCache bool }
func NewTableStruct ¶
func NewTableStruct(db *DB, tableName string, pointerType reflect.Type) *TableStruct
pointerType 必须为约定值 &struct
Click to show internal directories.
Click to hide internal directories.