Documentation ¶
Index ¶
- Variables
- func HandleFunc(handler func(tx *TX) error) func(db *gorm.DB) error
- func Rows2Bytes(rows *sql.Rows) []byte
- func Rows2Map(rows *sql.Rows) []map[string]interface{}
- type BaseModel
- type DB
- func OpenDBClickhouse(username, password, ip string, port uint64, dbName string, dryRun bool, ...) *DB
- func OpenDBClickhouseCluster(dsns []string, dryRun bool, maxConn, idleConn uint64) *DB
- func OpenDBMySQL(username, password, ip string, port uint64, dbName string, dryRun bool, ...) *DB
- func OpenDBMySQLCluster(dsns []string, dryRun bool, maxConn, idleConn uint64) *DB
- func OpenDBPostgreSQL(username, password, ip string, port uint64, dbName string, dryRun bool, ...) *DB
- func OpenDBPostgreSQLCluster(dsns []string, dryRun bool, maxConn, idleConn uint64) *DB
- func OpenDBSQLServer(username, password, ip string, port uint64, dbName string, dryRun bool, ...) *DB
- func OpenDBSQLServerCluster(dsns []string, dryRun bool, maxConn, idleConn uint64) *DB
- func OpenDBSQLite(filePath string, dryRun bool, maxConn, idleConn uint64, customConn string) *DB
- func OpenDBSQLiteCluster(fileNames []string, dryRun bool, maxConn, idleConn uint64, customConn string) *DB
- func OpenDBTiDB(username, password, ip string, port uint64, dbName string, dryRun bool, ...) *DB
- func OpenDBTiDBCluster(dsns []string, dryRun bool, maxConn, idleConn uint64) *DB
- func (db *DB) Create(dataModel interface{}) error
- func (db *DB) CreateBatch(dataModels interface{}, batchSize uint) error
- func (db *DB) DeleteHardById(dataModels interface{}) error
- func (db *DB) DeleteHardByWhere(dataModel interface{}, where string, args []interface{}) error
- func (db *DB) DeleteSoftById(dataModels interface{}) error
- func (db *DB) DeleteSoftByWhere(dataModel interface{}, where string, args []interface{}) error
- func (db *DB) Exec(sql string, values ...interface{}) error
- func (db *DB) InitDefaultData(basePath string)
- func (db *DB) Migration(models []interface{})
- func (db *DB) RawSqlForByte(sql string, values ...interface{}) ([]byte, error)
- func (db *DB) RawSqlForMap(sql string, values ...interface{}) ([]map[string]interface{}, error)
- func (db *DB) RetrieveByModel(pageSize, pageNo int, whereModel interface{}, order string) (interface{}, int64, error)
- func (db *DB) RetrieveByModelBytes(pageSize, pageNo int, whereModel interface{}, order string) ([]byte, int64, error)
- func (db *DB) RetrieveByModelSelect(pageSize, pageNo int, whereModel interface{}, fields []string, order string) (interface{}, int64, error)
- func (db *DB) RetrieveByModelSelectBytes(pageSize, pageNo int, whereModel interface{}, fields []string, order string) ([]byte, int64, error)
- func (db *DB) RetrieveByModelSelectString(pageSize, pageNo int, whereModel interface{}, fields []string, order string) (string, int64, error)
- func (db *DB) RetrieveByModelString(pageSize, pageNo int, whereModel interface{}, order string) (string, int64, error)
- func (db *DB) RetrieveByWhere(pageSize, pageNo int, dataModel interface{}, order, where string, ...) (interface{}, int64, error)
- func (db *DB) RetrieveByWhereBytes(pageSize, pageNo int, dataModel interface{}, order, where string, ...) ([]byte, int64, error)
- func (db *DB) RetrieveByWhereSelect(pageSize, pageNo int, dataModel interface{}, fields []string, ...) (interface{}, int64, error)
- func (db *DB) RetrieveByWhereSelectBytes(pageSize, pageNo int, dataModel interface{}, fields []string, ...) ([]byte, int64, error)
- func (db *DB) RetrieveByWhereSelectString(pageSize, pageNo int, dataModel interface{}, fields []string, ...) (string, int64, error)
- func (db *DB) RetrieveByWhereString(pageSize, pageNo int, dataModel interface{}, order, where string, ...) (string, int64, error)
- func (db *DB) RetrieveCountByArgs(dataModel interface{}, where string, args []interface{}) (int64, error)
- func (db *DB) RetrieveCountByModel(whereModel interface{}) (int64, error)
- func (db *DB) RetrieveFirstByArgs(dataModel interface{}, where string, args []interface{}) error
- func (db *DB) RetrieveFirstByFind(whereModel interface{}) error
- func (db *DB) RetrieveFirstById(whereModel interface{}) error
- func (db *DB) RetrieveFirstByMap(dataModel interface{}, whereMap map[string]interface{}) error
- func (db *DB) RetrieveLastByArgs(dataModel interface{}, where string, args []interface{}) error
- func (db *DB) RetrieveLastByFind(whereModel interface{}) error
- func (db *DB) RetrieveLastById(whereModel interface{}) error
- func (db *DB) RetrieveLastByMap(dataModel interface{}, whereMap map[string]interface{}) error
- func (db *DB) RetrieveOrderInByModel(pageSize, pageNo int, whereModel interface{}, orderKey string, ...) (interface{}, int64, error)
- func (db *DB) RetrieveOrderInByModelBytes(pageSize, pageNo int, whereModel interface{}, orderKey string, ...) ([]byte, int64, error)
- func (db *DB) RetrieveOrderInByModelSelect(pageSize, pageNo int, whereModel interface{}, fields []string, orderKey string, ...) (interface{}, int64, error)
- func (db *DB) RetrieveOrderInByModelSelectBytes(pageSize, pageNo int, whereModel interface{}, fields []string, orderKey string, ...) ([]byte, int64, error)
- func (db *DB) RetrieveOrderInByModelSelectString(pageSize, pageNo int, whereModel interface{}, fields []string, orderKey string, ...) (string, int64, error)
- func (db *DB) RetrieveOrderInByModelString(pageSize, pageNo int, whereModel interface{}, orderKey string, ...) (string, int64, error)
- func (db *DB) RetrieveOrderInByWhere(pageSize, pageNo int, dataModel interface{}, where string, args []interface{}, ...) (interface{}, int64, error)
- func (db *DB) RetrieveOrderInByWhereBytes(pageSize, pageNo int, dataModel interface{}, where string, args []interface{}, ...) ([]byte, int64, error)
- func (db *DB) RetrieveOrderInByWhereSelect(pageSize, pageNo int, dataModel interface{}, fields []string, where string, ...) (interface{}, int64, error)
- func (db *DB) RetrieveOrderInByWhereSelectBytes(pageSize, pageNo int, dataModel interface{}, fields []string, where string, ...) ([]byte, int64, error)
- func (db *DB) RetrieveOrderInByWhereSelectString(pageSize, pageNo int, dataModel interface{}, fields []string, where string, ...) (string, int64, error)
- func (db *DB) RetrieveOrderInByWhereString(pageSize, pageNo int, dataModel interface{}, where string, args []interface{}, ...) (string, int64, error)
- func (db *DB) Transaction(fc func(tx *TX) error) error
- func (db *DB) TruncateTable(dataModel interface{}) error
- func (db *DB) UpdateByArgsField(dataModel interface{}, where string, args []interface{}, column, expr string, ...) error
- func (db *DB) UpdateByArgsWhere(dataModel interface{}, where string, args []interface{}, ...) error
- func (db *DB) UpdateByArgsWhereModel(where string, args []interface{}, updateModel interface{}) error
- func (db *DB) UpdateByField(dataModel interface{}, where interface{}, column, expr string, ...) error
- func (db *DB) UpdateById(dataModel interface{}) error
- func (db *DB) UpdateByModelField(whereModel interface{}, column, expr string, updates ...interface{}) error
- func (db *DB) UpdateByModelWhere(whereModel interface{}, updates map[string]interface{}) error
- func (db *DB) UpdateByModelWhereModel(whereModel interface{}, updateModel interface{}) error
- func (db *DB) UpdateByWhere(dataModel interface{}, where string, updates map[string]interface{}) error
- func (db *DB) UpdateByWhereModel(where string, updateModel interface{}) error
- type LogInfoModel
- type TX
- type UpdateModel
Constants ¶
This section is empty.
Variables ¶
View Source
var ( DefaultMaxConn uint64 = 2000 DefaultIdleConn uint64 = 20 )
View Source
var ( DefaultLimit = 10 DefaultMaxLimit = 1000 )
Functions ¶
func Rows2Bytes ¶
Types ¶
type BaseModel ¶
type BaseModel struct { Id uint64 `json:"id" gorm:"primary_key;AUTO_INCREMENT;column:id;comment:'主键ID'"` IsDel uint64 `json:"-" gorm:"column:is_del;default:0;comment:'删除标志'"` CreatedAt time.Time `json:"created_at" gorm:"column:created_at;comment:'创建时间'"` UpdatedAt time.Time `json:"updated_at" gorm:"column:updated_at;comment:'更新时间'"` DeletedAt *time.Time `json:"-" gorm:"column:deleted_at;comment:'删除时间'" sql:"index"` Remark string `json:"remark" gorm:"column:remark;null;type:text;comment:'备注信息'"` }
type DB ¶
func OpenDBClickhouse ¶
func OpenDBClickhouseCluster ¶ added in v0.1.6
func OpenDBMySQL ¶
func OpenDBMySQLCluster ¶ added in v0.1.6
func OpenDBPostgreSQL ¶
func OpenDBPostgreSQLCluster ¶ added in v0.1.6
func OpenDBSQLServer ¶
func OpenDBSQLServerCluster ¶ added in v0.1.6
func OpenDBSQLite ¶
func OpenDBSQLiteCluster ¶ added in v0.1.6
func OpenDBTiDB ¶
func OpenDBTiDBCluster ¶ added in v0.1.6
func (*DB) CreateBatch ¶
func (*DB) DeleteHardById ¶
func (*DB) DeleteHardByWhere ¶
func (*DB) DeleteSoftById ¶
func (*DB) DeleteSoftByWhere ¶
func (*DB) InitDefaultData ¶
func (*DB) RawSqlForByte ¶
func (*DB) RawSqlForMap ¶
func (*DB) RetrieveByModel ¶
func (*DB) RetrieveByModelBytes ¶
func (*DB) RetrieveByModelSelect ¶
func (*DB) RetrieveByModelSelectBytes ¶
func (*DB) RetrieveByModelSelectString ¶
func (*DB) RetrieveByModelString ¶
func (*DB) RetrieveByWhere ¶
func (*DB) RetrieveByWhereBytes ¶
func (*DB) RetrieveByWhereSelect ¶
func (*DB) RetrieveByWhereSelectBytes ¶
func (*DB) RetrieveByWhereSelectString ¶
func (*DB) RetrieveByWhereString ¶
func (*DB) RetrieveCountByArgs ¶
func (*DB) RetrieveCountByModel ¶
func (*DB) RetrieveFirstByArgs ¶ added in v0.1.7
func (*DB) RetrieveFirstByFind ¶ added in v0.1.7
func (*DB) RetrieveFirstById ¶ added in v0.1.7
func (*DB) RetrieveFirstByMap ¶ added in v0.1.7
func (*DB) RetrieveLastByArgs ¶ added in v0.1.7
func (*DB) RetrieveLastByFind ¶ added in v0.1.7
func (*DB) RetrieveLastById ¶ added in v0.1.7
func (*DB) RetrieveLastByMap ¶ added in v0.1.7
func (*DB) RetrieveOrderInByModel ¶ added in v0.1.7
func (*DB) RetrieveOrderInByModelBytes ¶ added in v0.1.7
func (*DB) RetrieveOrderInByModelSelect ¶ added in v0.1.7
func (*DB) RetrieveOrderInByModelSelectBytes ¶ added in v0.1.7
func (*DB) RetrieveOrderInByModelSelectString ¶ added in v0.1.7
func (*DB) RetrieveOrderInByModelString ¶ added in v0.1.7
func (*DB) RetrieveOrderInByWhere ¶ added in v0.1.7
func (*DB) RetrieveOrderInByWhereBytes ¶ added in v0.1.7
func (*DB) RetrieveOrderInByWhereSelect ¶ added in v0.1.7
func (*DB) RetrieveOrderInByWhereSelectBytes ¶ added in v0.1.7
func (*DB) RetrieveOrderInByWhereSelectString ¶ added in v0.1.7
func (*DB) RetrieveOrderInByWhereString ¶ added in v0.1.7
func (*DB) TruncateTable ¶
func (*DB) UpdateByArgsField ¶
func (*DB) UpdateByArgsWhere ¶
func (*DB) UpdateByArgsWhereModel ¶
func (*DB) UpdateByField ¶
func (*DB) UpdateById ¶
func (*DB) UpdateByModelField ¶
func (*DB) UpdateByModelWhere ¶
func (*DB) UpdateByModelWhereModel ¶
func (*DB) UpdateByWhere ¶
func (*DB) UpdateByWhereModel ¶
type LogInfoModel ¶
type LogInfoModel struct { BaseModel Method string `json:"method" gorm:"column:method;null;comment:'请求方法'"` ContentLength uint64 `json:"content_length" gorm:"column:content_length;null;comment:'内容长度'"` ExecuteTime time.Time `json:"execute_time" gorm:"column:execute_time;null;comment:'执行时间'"` ContentType string `json:"content_type" gorm:"column:content_type;null;comment:'内容类型'"` CostTime uint64 `json:"cost_time" gorm:"column:cost_time;null;comment:'花费时间'"` RequestUrl string `json:"request_url" gorm:"column:request_url;null;comment:'请求URL'"` RequestHost string `json:"request_host" gorm:"column:request_host;null;comment:'请求主机'"` UserAgent string `json:"user_agent" gorm:"column:user_agent;null;comment:'请求头'"` RemoteIp string `json:"remote_ip" gorm:"column:remote_ip;null;comment:'远程IP'"` RemoteAddr string `json:"remote_addr" gorm:"column:remote_addr;null;comment:'远程地址'"` ApiPath string `json:"api_path" gorm:"column:api_path;null;comment:'API路径'"` Referer string `json:"referer" gorm:"column:referer;null;comment:'网页关联'"` ApiDesc string `json:"api_desc" gorm:"column:api_desc;null;comment:'API功能'"` StatusCode int `json:"status_code" gorm:"column:status_code;null;comment:'状态码'"` ResponseData string `json:"response_data" gorm:"column:response_data;null;type:text;comment:'响应数据'"` AccountInfo string `json:"account_info" gorm:"column:account_info;null;type:text;comment:'用户信息'"` AccountName string `json:"account_name" gorm:"column:account_name;null;comment:'用户名称'"` AccountId uint64 `json:"account_id" gorm:"column:account_id;null;comment:'用户ID'"` RequestParams string `json:"request_params" gorm:"column:request_params;null;type:text;comment:'请求参数'"` RequestToken string `json:"request_token" gorm:"column:request_token;null;type:text;comment:'请求Token'"` }
func (*LogInfoModel) TableName ¶
func (m *LogInfoModel) TableName() string
type UpdateModel ¶
type UpdateModel struct { BaseModel FileName string `json:"file_name" gorm:"column:file_name;not null;comment:'文件名称'"` ExecuteTime time.Time `json:"execute_time" gorm:"column:execute_time;null;comment:'执行时间'"` }
func (*UpdateModel) TableName ¶
func (m *UpdateModel) TableName() string
Click to show internal directories.
Click to hide internal directories.