Documentation ¶
Index ¶
- Constants
- func CloseDB(db *gorm.DB) (err error)
- func Connect(fp, field string, debugMode bool) (db *gorm.DB, err error)
- func ConnectDSN(dsn string, debugMode bool) (db *gorm.DB, err error)
- func InitDB(db *gorm.DB) (err error)
- func IsDuplicateEntry(err error) bool
- func IsNotFound(err error) bool
- func JSONContains(tx *gorm.DB, field string, val any, contains bool) *gorm.DB
- func JSONIsNull(tx *gorm.DB, field string, isNull bool) *gorm.DB
- func Like(tx *gorm.DB, field, val string) *gorm.DB
- func MultiEquals[T any](tx *gorm.DB, field string, values []T) *gorm.DB
- func Where(tx *gorm.DB, field, val string) *gorm.DB
- type Map
- type Query
- type QueryDate
- type Result
- type Vector
Constants ¶
View Source
const ( PageSizeMin = 10 PageSizeMax = 50 )
Variables ¶
This section is empty.
Functions ¶
func Connect ¶
connect to database by provide a config file path(under project directory), and then use field mysql.dsn
func ConnectDSN ¶
MySQL initialize
dsn format: {USERANME}:{PASSWORD}@tcp({IP})/{DATABASE}?charset=utf8mb4&parseTime=True&loc=Local
func IsDuplicateEntry ¶
func JSONIsNull ¶
to avoid use this func, you can't bind field to an pointer rather than a structure
Types ¶
type Query ¶
type Query struct { Starting string `json:"starting,omitempty" form:"starting"` // 2022-10-28 End string `json:"end,omitempty" form:"end"` // 2022-10-28 PageNo int `json:"pageNo,omitempty" form:"pageNo"` PageSize int `json:"pageSize,omitempty" form:"pageSize"` Search string `json:"search,omitempty" form:"search"` Status string `json:"status,omitempty" form:"status"` UserId int64 `json:"-" form:"-"` }
query
type QueryDate ¶
Click to show internal directories.
Click to hide internal directories.