Documentation ¶
Index ¶
- Variables
- func ChunkByIDMaxMin(size int64, db *gorm.DB, dest interface{}, callback ChunkCallback, l Logger, ...) (err error)
- func JSONScanner(f interface{}, value interface{}) error
- func JSONValuer(f interface{}) (driver.Value, error)
- func MaxMinID(db *gorm.DB) (max, min int64, err error)
- func TableName(db *gorm.DB) string
- type ChunkCallback
- type Column
- type DefaultLogger
- type Key
- type Logger
- type NoLogger
- type OrderParam
- type PageParam
- type PageResult
- type Schema
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrBreakChunk = errors.New("break the chunk while")
ErrBreakChunk break the chunk while callback return error
Functions ¶
func ChunkByIDMaxMin ¶
func ChunkByIDMaxMin(size int64, db *gorm.DB, dest interface{}, callback ChunkCallback, l Logger, extra ...func(db *gorm.DB) *gorm.DB) (err error)
ChunkByIDMaxMin process data in chunks, scope by id
func JSONScanner ¶
func JSONScanner(f interface{}, value interface{}) error
JSONScanner decoding DB field(JSON string) to custom type
func JSONValuer ¶
JSONValuer encoding custom type to JSON string
Types ¶
type Column ¶
type Column struct { Name string `json:"name"` Type string `json:"type"` NotNull bool `json:"not_null"` Unsigned bool `json:"unsigned"` AutoIncrement bool `json:"auto_increment"` Charset string `json:"charset"` Collate string `json:"collate"` Default interface{} `json:"default"` Comment string `json:"comment"` }
Column table field info
type DefaultLogger ¶
type DefaultLogger struct{}
DefaultLogger default logger, console output
func (*DefaultLogger) Debug ¶
func (*DefaultLogger) Debug(v ...interface{})
Debug log a debug message
func (*DefaultLogger) Error ¶
func (*DefaultLogger) Error(v ...interface{})
Error log a error message
type Key ¶
type Key struct { Name string `json:"name"` IndexType string `json:"index_type"` IndexMethod string `json:"index_method"` Comment string `json:"comment"` Columns []string `json:"columns"` }
Key table index key
type Logger ¶
type Logger interface { Debug(...interface{}) Info(...interface{}) Error(...interface{}) }
Logger log message
type OrderParam ¶
type OrderParam struct { OrderBy string `json:"order_by"` // (optional) column name, or SQL ORDER statement OrderType string `json:"order_type"` // (optional) ASC/DESC }
OrderParam params of order by statement
type PageParam ¶
type PageParam struct { CurrPage int `json:"curr_page" binding:"number"` // (optional) current page number, default 1 PageSize int `json:"page_size" binding:"number"` // (optional) number of per page, default 10 IgnorePage int `json:"ignore_page,omitempty"` // (optional) no paging and no total count, while not 0 }
PageParam uniform paging parameters
type PageResult ¶
type PageResult struct { PageParam TotalCount int `json:"total_count"` CurrCount int `json:"curr_count"` }
PageResult unified paging response structure
type Schema ¶
type Schema struct { RawDDL string `json:"-"` TableName string `json:"table_name"` Engine string `json:"engine"` AutoIncrement uint64 `json:"auto_increment"` DefaultCharset string `json:"default_charset"` DefaultCollation string `json:"default_collation"` Comment string `json:"comment"` Columns []*Column `json:"columns"` Keys []*Key `json:"keys"` }
Schema table schema info
Click to show internal directories.
Click to hide internal directories.