Documentation
¶
Index ¶
- Constants
- func AddMySQLBootstrapCallback(cbk MySQLBootstrapCallback)
- func GetMySQL() *gorm.DB
- func InitMySQL(rail miso.Rail, p MySQLConnParam) error
- func InitMySQLFromProp(rail miso.Rail) error
- func IsMySQLInitialized() bool
- func NewMySQLConn(rail miso.Rail, p MySQLConnParam) (*gorm.DB, error)
- func QueryPage[Res any](rail miso.Rail, tx *gorm.DB, p QueryPageParam[Res]) (miso.PageRes[Res], error)
- type ChainedPageQuery
- type MySQLBootstrapCallback
- type MySQLConnParam
- type Nilable
- type NilableValue
- type PageQuery
- func (pq *PageQuery[V]) Scan(rail miso.Rail, reqPage miso.Paging) (miso.PageRes[V], error)
- func (pq *PageQuery[V]) Transform(t util.Transform[V]) *PageQuery[V]
- func (pq *PageQuery[V]) WithBaseQuery(qry ChainedPageQuery) *PageQuery[V]
- func (pq *PageQuery[V]) WithSelectQuery(qry ChainedPageQuery) *PageQuery[V]
- type PageQueryBuilder
- type Query
- func (q *Query) And(f func(*Query) *Query) *Query
- func (q *Query) Between(col string, args ...any) *Query
- func (q *Query) CopyNew() *Query
- func (q *Query) DB() *gorm.DB
- func (q *Query) Eq(col string, args ...any) *Query
- func (q *Query) EqIf(cond bool, col string, args ...any) *Query
- func (q *Query) Exec(sql string, args ...any) (rowsAffected int64, err error)
- func (q *Query) From(table string) *Query
- func (q *Query) Ge(col string, args ...any) *Query
- func (q *Query) GeIf(cond bool, col string, args ...any) *Query
- func (q *Query) Group(name string) *Query
- func (q *Query) Gt(col string, args ...any) *Query
- func (q *Query) GtIf(cond bool, col string, args ...any) *Query
- func (q *Query) If(cond bool, f func(*Query) *Query) *Query
- func (q *Query) IsNotNull(col string) *Query
- func (q *Query) IsNull(col string) *Query
- func (q *Query) Join(query string, args ...any) *Query
- func (q *Query) JoinIf(addJoin bool, query string, args ...any) *Query
- func (q *Query) Le(col string, args ...any) *Query
- func (q *Query) LeIf(cond bool, col string, args ...any) *Query
- func (q *Query) Like(col string, val string) *Query
- func (q *Query) LikeIf(cond bool, col string, val string) *Query
- func (q *Query) LikeLeft(col string, val string) *Query
- func (q *Query) LikeLeftIf(cond bool, col string, val string) *Query
- func (q *Query) LikeRight(col string, val string) *Query
- func (q *Query) LikeRightIf(cond bool, col string, val string) *Query
- func (q *Query) Limit(n int) *Query
- func (q *Query) Lt(col string, args ...any) *Query
- func (q *Query) LtIf(cond bool, col string, args ...any) *Query
- func (q *Query) Offset(n int) *Query
- func (q *Query) Or(query string, args ...any) *Query
- func (q *Query) OrFunc(f func(*Query) *Query) *Query
- func (q *Query) OrIf(cond bool, query string, args ...any) *Query
- func (q *Query) Order(order string) *Query
- func (q *Query) Raw(sql string, args ...any) *Query
- func (q *Query) Scan(ptr any) (rowsAffected int64, err error)
- func (q *Query) Select(cols string, args ...any) *Query
- func (q *Query) Set(col string, arg any) *Query
- func (q *Query) SetIf(cond bool, col string, arg any) *Query
- func (q *Query) Update() (rowsAffected int64, err error)
- func (q *Query) Where(query string, args ...any) *Query
- func (q *Query) WhereFunc(f func(*Query) *Query) *Query
- func (q *Query) WhereIf(addWhere bool, query string, args ...any) *Query
- type QueryPageParam
- func (q *QueryPageParam[V]) Exec(rail miso.Rail, tx *gorm.DB) (miso.PageRes[V], error)
- func (q *QueryPageParam[V]) ForEach(t util.Transform[V]) *QueryPageParam[V]
- func (q *QueryPageParam[V]) WithBaseQuery(qry PageQueryBuilder) *QueryPageParam[V]
- func (q *QueryPageParam[V]) WithPage(p miso.Paging) *QueryPageParam[V]
- func (q *QueryPageParam[V]) WithSelectQuery(qry PageQueryBuilder) *QueryPageParam[V]
Constants ¶
View Source
const ( /* ------------------------------------ Prop for MySQL ------------------------------------ */ PropMySQLEnabled = "mysql.enabled" PropMySQLUser = "mysql.user" PropMySQLPassword = "mysql.password" PropMySQLSchema = "mysql.database" PropMySQLHost = "mysql.host" PropMySQLPort = "mysql.port" PropMySQLConnParam = "mysql.connection.parameters" PropMySQLConnLifetime = "mysql.connection.lifetime" PropMySQLMaxOpenConns = "mysql.connection.open.max" PropMySQLMaxIdleConns = "mysql.connection.idle.max" )
Variables ¶
This section is empty.
Functions ¶
func AddMySQLBootstrapCallback ¶
func AddMySQLBootstrapCallback(cbk MySQLBootstrapCallback)
func InitMySQL ¶
func InitMySQL(rail miso.Rail, p MySQLConnParam) error
Init Handle to the database
If mysql client has been initialized, current func call will be ignored.
func InitMySQLFromProp ¶
Init connection to mysql
If mysql client has been initialized, current func call will be ignored.
This func looks for following props:
"mysql.user" "mysql.password" "mysql.database" "mysql.host" "mysql.port" "mysql.connection.parameters"
func NewMySQLConn ¶
Create new MySQL connection
func QueryPage ¶
func QueryPage[Res any](rail miso.Rail, tx *gorm.DB, p QueryPageParam[Res]) (miso.PageRes[Res], error)
Execute paged query.
COUNT query is called first, if none is found (i.e., COUNT(...) == 0), this method will not call the actual SELECT query to avoid unnecessary performance lost.
Types ¶
type ChainedPageQuery ¶ added in v0.1.10
type MySQLConnParam ¶
type NilableValue ¶ added in v0.1.13
type NilableValue struct {
// contains filtered or unexported fields
}
func (*NilableValue) IsZero ¶ added in v0.1.13
func (n *NilableValue) IsZero() bool
func (*NilableValue) MarkZero ¶ added in v0.1.13
func (n *NilableValue) MarkZero(isZero bool)
type PageQuery ¶ added in v0.1.10
type PageQuery[V any] struct { // contains filtered or unexported fields }
Create param for page query.
func (*PageQuery[V]) WithBaseQuery ¶ added in v0.1.10
func (pq *PageQuery[V]) WithBaseQuery(qry ChainedPageQuery) *PageQuery[V]
func (*PageQuery[V]) WithSelectQuery ¶ added in v0.1.10
func (pq *PageQuery[V]) WithSelectQuery(qry ChainedPageQuery) *PageQuery[V]
type Query ¶ added in v0.1.6
type Query struct {
// contains filtered or unexported fields
}
func (*Query) LikeLeftIf ¶ added in v0.1.9
LIKE '%?'
func (*Query) LikeRightIf ¶ added in v0.1.9
LIKE '?%'
type QueryPageParam ¶
type QueryPageParam[V any] struct { // contains filtered or unexported fields }
Create param for page query.
func NewPageQuery ¶
func NewPageQuery[Res any]() *QueryPageParam[Res]
func (*QueryPageParam[V]) ForEach ¶
func (q *QueryPageParam[V]) ForEach(t util.Transform[V]) *QueryPageParam[V]
func (*QueryPageParam[V]) WithBaseQuery ¶
func (q *QueryPageParam[V]) WithBaseQuery(qry PageQueryBuilder) *QueryPageParam[V]
func (*QueryPageParam[V]) WithPage ¶
func (q *QueryPageParam[V]) WithPage(p miso.Paging) *QueryPageParam[V]
func (*QueryPageParam[V]) WithSelectQuery ¶
func (q *QueryPageParam[V]) WithSelectQuery(qry PageQueryBuilder) *QueryPageParam[V]
Click to show internal directories.
Click to hide internal directories.