Documentation
¶
Index ¶
- func Delete(db *gorm.DB, tableName string, column string, value any) error
- func DeleteById(db *gorm.DB, tableName string, id uint64) error
- func Exists(db *gorm.DB, tableName, column string, value interface{}, withDeletedAt bool) (bool, error)
- func ExistsByColumn(db *gorm.DB, tableName, column string, value interface{}) (bool, error)
- func ExistsByColumnWithDeletedAt(db *gorm.DB, tableName, column string, value interface{}) (bool, error)
- func ExistsByFilterExprs(db *gorm.DB, tableName string, filters sql2.FilterExprs) (bool, error)
- func ExistsByQuery(db *gorm.DB, qsql string, value ...any) (bool, error)
- func ExistsBySQL(db *gorm.DB, sql string, value ...any) (bool, error)
- func GetById[T any](db *gorm.DB, id any) (*T, error)
- func NewDBWithContext(db *gorm.DB, ctx context.Context) *gorm.DB
- func NewDBWithLogger(db *gorm.DB, log *log.Logger, conf *logger.Config) *gorm.DB
- func NewTraceDB(db *gorm.DB, ctx context.Context, traceId string) *gorm.DB
- func TableName(tx *gorm.DB, name string) *gorm.DB
- type ChainRepository
- type Config
- type Mysql
- type Postgres
- type PrometheusConfig
- type Repository
- type Sqlite
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ExistsByColumn ¶
func ExistsByColumnWithDeletedAt ¶ added in v0.3.8
func ExistsByFilterExprs ¶
func ExistsByQuery ¶ added in v0.6.0
根据查询语句查询数据是否存在
func NewDBWithContext ¶ added in v0.0.40
func NewDBWithLogger ¶ added in v0.0.40
Types ¶
type ChainRepository ¶ added in v0.0.32
type ChainRepository[T any] struct { scope.ChainScope *gorm.DB }
func NewChainRepository ¶ added in v0.0.32
func NewChainRepository[T any](db *gorm.DB) *ChainRepository[T]
type Config ¶
type Config struct {
Type, Charset, Database, TimeZone string
Host string
Port int32
User, Password string
Postgres Postgres
Mysql Mysql
Sqlite Sqlite
MaxIdleConns, MaxOpenConns int
ConnMaxLifetime, ConnMaxIdleTime time.Duration
Gorm gorm.Config
EnableStdLogger bool
Logger logger.Config
NamingStrategy schema.NamingStrategy
EnablePrometheus bool
Prometheus prometheus.Config
PrometheusConfigs []PrometheusConfig
}
type PrometheusConfig ¶
type Repository ¶ added in v0.0.32
func NewRepository ¶
func NewRepository[T any](db *gorm.DB) *Repository[T]
func (*Repository[T]) Create ¶ added in v0.0.32
func (r *Repository[T]) Create(t *T) error
func (*Repository[T]) Delete ¶ added in v0.0.32
func (r *Repository[T]) Delete(id any) error
func (*Repository[T]) Retrieve ¶ added in v0.0.32
func (r *Repository[T]) Retrieve(id any) (*T, error)
func (*Repository[T]) Update ¶ added in v0.0.32
func (r *Repository[T]) Update(t *T) error
Click to show internal directories.
Click to hide internal directories.