Documentation
¶
Index ¶
- Constants
- func GenPreloadItemArgs(args ...interface{}) []interface{}
- func GenPreloadItemHandlerFunc(handler func(db *gorm.DB) *gorm.DB) []interface{}
- func NewDefaultMysqlGormConn(conn *Connection, dbUrl string, debug bool) *gorm.DB
- type Action
- type AtMysql
- type Connection
- type FilterItem
- type FilterOperator
- type FilterOrderBy
- type Filters
- type IBaseRepository
- type Limit
- type OrderBy
- type PreloadArgsFunc
- type PreloadItem
- type Preloads
Constants ¶
View Source
const ( WriteOrRead = Action(1) ReadOnly = Action(2) )
View Source
const ( EqualOperator = FilterOperator("=") LikeOperator = FilterOperator("like") InOperator = FilterOperator("in") LessThanOperator = FilterOperator("<") GreaterThanOperator = FilterOperator(">") NotInOperator = FilterOperator("not in") LessThanOrEqualOperator = FilterOperator("<=") // zero value ZeroLimit = Limit(-1) ZeroOrderBy = OrderBy("") IDFieldName = "id" )
View Source
const ( // MaxOpenConn -- MaxOpenConn = 100 // MaxIdleConn -- MaxIdleConn = 10 )
Variables ¶
This section is empty.
Functions ¶
func GenPreloadItemArgs ¶
func GenPreloadItemArgs(args ...interface{}) []interface{}
func NewDefaultMysqlGormConn ¶
func NewDefaultMysqlGormConn(conn *Connection, dbUrl string, debug bool) *gorm.DB
NewDefaultMysqlGormConn --
Types ¶
type AtMysql ¶
AtMysql --
func CreateMysqlConnection ¶
func CreateMysqlConnection(conn *Connection) *AtMysql
CreateMysqlConnection --
func NewConnection ¶
func NewConnection(conn *Connection) (*AtMysql, error)
NewConnection -- open connection to db
type Connection ¶
type Connection struct { Host string Port int Protocol string User string Password string DatabaseName string Charset string ParseTime bool Location string Others string EnableLog bool MaxOpenConn int MaxIdleConn int ServiceName string }
Connection -- mysql connection
func DefaultMysqlConnectionFromConfig ¶
func DefaultMysqlConnectionFromConfig() *Connection
DefaultMysqlConnectionFromConfig -- load connection settings in config with default key
type FilterItem ¶
type FilterItem struct { FieldName string Operator FilterOperator Value interface{} // these fields are used for this statement: db.Where(a.RawQuery, a.Args...) RawQuery string Args []interface{} // contains filtered or unexported fields }
type FilterOperator ¶
type FilterOperator string
type FilterOrderBy ¶
type FilterOrderBy struct{}
type Filters ¶
type Filters []FilterItem
type IBaseRepository ¶
type IBaseRepository interface { GetDB(actions ...Action) *gorm.DB FindOneHandler(ctx context.Context, result interface{}, args ...interface{}) error FindByIDHandler(ctx context.Context, ID int, result interface{}, args ...interface{}) error FindsHandler(ctx context.Context, result interface{}, args ...interface{}) error // contains filtered or unexported methods }
func NewBaseRepository ¶
func NewBaseRepository(masterDB *gorm.DB, replicaDB ...*gorm.DB) IBaseRepository
type PreloadArgsFunc ¶
Example
func(db *gorm.DB) *gorm.DB { return db.Where("info_type = 0") // schema_markup }
type PreloadItem ¶
type PreloadItem struct { Column string Args []interface{} // contains filtered or unexported fields }
type Preloads ¶
type Preloads []PreloadItem
Click to show internal directories.
Click to hide internal directories.