Documentation
¶
Index ¶
- func GormCloseDB(db *gorm.DB) (err error)
- func GormEquals[T comparable](tx *gorm.DB, field string, values []T) *gorm.DB
- func GormFlip(tx *gorm.DB, pageSize, pageIndex int) *gorm.DB
- func GormFmtExpr(state string, a []any, b ...any) clause.Expr
- func GormTransaction(db *gorm.DB, state string, a ...any) (err error)
- func MigratePgDir(dsn, migrations string) (err error)
- func MigratePgFs(dsn string, src embed.FS, subpath string) (err error)
- func NewRedisClient(vp *viper.Viper) (client *redis.Client, err error)
- func PgArrayContains[T any](tx *gorm.DB, field string, value T) *gorm.DB
- func PgArrayIncludes[T any](tx *gorm.DB, field string, arr []T) *gorm.DB
- func PgArrayPush[T any](field string, value T) clause.Expr
- func PgConcateArrays[T any](tx *gorm.DB, field string, arr []T) clause.Expr
- func PgConnect(vp *viper.Viper, release bool) (gormDB *gorm.DB, sqlDB *sql.DB, err error)
- func PgFindTables(db *gorm.DB, m string) (tables []string, err error)
- func PgMergeArrays[T any](field string, arr []T) clause.Expr
- func PgNotFound(err error) bool
- func PgTableExists(db *gorm.DB, table string) (existence bool, err error)
- func PgTimestamptz(t ...time.Time) []byte
- func PgUniqueViolation(err error) bool
- func SQLxCol(table string) func(...string) string
- func SQLxInStrings[T uuid.UUID](ids []T) string
- func SQLxOrStrings[T uuid.UUID | string](field string, ids []T) string
- type GormDate
- type GormJSONAny
- type GormJSONArray
- type GormJSONMap
- type GormUUIDs
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GormCloseDB ¶
func GormEquals ¶
Abandoned, GormEquals(_DB.Table("accounts"), "id", ids).Delete(nil)
func MigratePgDir ¶
func NewRedisClient ¶
func PgConcateArrays ¶
#### concat to array
func PgConnect ¶
dsn: - postgres://{USERANME}:{PASSWORD}@tcp({IP})/{DATABASE}?sslmode=disable - "host=%s user=%s password=%s dbname=%s port=5432 sslmode=disable TimeZone=Asia/Shanghai"
func PgFindTables ¶
"sys_.*", "sys_\\d+$"
func PgMergeArrays ¶
#### push to array and remove duplicates
func PgNotFound ¶
func PgTimestamptz ¶
func PgUniqueViolation ¶
!!! works as expected only version(gorm.io/driver/postgres) <= v1.4.5
and errors.Is(e, gorm.ErrDuplicatedKey) doesn't work as expected
func SQLxInStrings ¶
func SQLxInStrings[T uuid.UUID | string](ids []T) string {
Types ¶
type GormJSONAny ¶
type GormJSONAny[T any] struct { Item T }
GormJSON
func (GormJSONAny[T]) MarshalJSON ¶
func (self GormJSONAny[T]) MarshalJSON() ([]byte, error)
func (*GormJSONAny[T]) Scan ¶
func (self *GormJSONAny[T]) Scan(value any) (err error)
func (*GormJSONAny[T]) UnmarshalJSON ¶
func (self *GormJSONAny[T]) UnmarshalJSON(data []byte) error
type GormJSONArray ¶
type GormJSONArray[T any] []T
GormJSONArray, json array
func (*GormJSONArray[T]) Scan ¶
func (self *GormJSONArray[T]) Scan(value any) (err error)
type GormJSONMap ¶
GormJSONMap, json map
func (GormJSONMap[T]) JSON ¶
func (self GormJSONMap[T]) JSON() (bts []byte)
func (*GormJSONMap[T]) Scan ¶
func (self *GormJSONMap[T]) Scan(value any) (err error)
type GormUUIDs ¶
https://github.com/jackc/pgx/issues/1781
func NewGormUUIDs ¶
func (*GormUUIDs) FromStrings ¶
Click to show internal directories.
Click to hide internal directories.