Documentation ¶
Index ¶
- Constants
- Variables
- func BuildBooleanFilter(field string, filter *query.BooleanFilterOperators) func(db *gorm.DB) *gorm.DB
- func BuildDateFilter(field string, filter *query.DateFilterOperators) func(db *gorm.DB) *gorm.DB
- func BuildDoubleFilter(field string, filter *query.DoubleFilterOperators) func(db *gorm.DB) *gorm.DB
- func BuildFloatFilter(field string, filter *query.FloatFilterOperators) func(db *gorm.DB) *gorm.DB
- func BuildInt32Filter(field string, filter *query.Int32FilterOperators) func(db *gorm.DB) *gorm.DB
- func BuildInt64Filter(field string, filter *query.Int64FilterOperators) func(db *gorm.DB) *gorm.DB
- func BuildNullFilter(field string, filter *query.NullFilterOperators) func(db *gorm.DB) *gorm.DB
- func BuildStringFilter(field string, filter *query.StringFilterOperation) func(db *gorm.DB) *gorm.DB
- func NewConnStrResolver(c *conf.Endpoints, ts saas.TenantStore) data.ConnStrResolver
- func NewDbGuardianContext(ctx context.Context, enable ...bool) context.Context
- func NewDbProvider(cache *DbCache, cs data.ConnStrResolver, d *conf.Data) sgorm.DbProvider
- func PageScope(page query.Page) func(db *gorm.DB) *gorm.DB
- func RegisterCallbacks(db *gorm.DB)
- func SortScope(sort query.Sort, d []string) func(db *gorm.DB) *gorm.DB
- func WhereUserId(id interface{}) func(db *gorm.DB) *gorm.DB
- type AuditedModel
- type BuildDetailScope
- type BuildFilterScope
- type BuildPageScope
- type BuildSortScope
- type DbCache
- type DbProviderFunc
- type DefaultSorting
- type GetDb
- type Logger
- func (l *Logger) Error(ctx context.Context, s string, i ...interface{})
- func (l *Logger) Info(ctx context.Context, s string, i ...interface{})
- func (l *Logger) LogMode(level logger.LogLevel) logger.Interface
- func (l *Logger) Trace(ctx context.Context, begin time.Time, ...)
- func (l *Logger) Warn(ctx context.Context, s string, i ...interface{})
- type Repo
- func (r *Repo[TEntity, TKey, TQuery]) BatchCreate(ctx context.Context, entity []*TEntity, batchSize int) error
- func (r *Repo[TEntity, TKey, TQuery]) Count(ctx context.Context, query *TQuery) (total int64, filtered int64, err error)
- func (r *Repo[TEntity, TKey, TQuery]) Create(ctx context.Context, entity *TEntity) error
- func (r *Repo[TEntity, TKey, TQuery]) Delete(ctx context.Context, id TKey) error
- func (r *Repo[TEntity, TKey, TQuery]) First(ctx context.Context, query *TQuery) (*TEntity, error)
- func (r *Repo[TEntity, TKey, TQuery]) Get(ctx context.Context, id TKey) (*TEntity, error)
- func (r *Repo[TEntity, TKey, TQuery]) List(ctx context.Context, query *TQuery) ([]*TEntity, error)
- func (r *Repo[TEntity, TKey, TQuery]) Update(ctx context.Context, id TKey, entity *TEntity, p query.Select) error
- func (r *Repo[TEntity, TKey, TQuery]) Upsert(ctx context.Context, entity *TEntity) error
- type UIDBase
- type UpdateAssociation
Constants ¶
View Source
const (
ConcurrentUpdateCode = "CONCURRENT_UPDATE"
)
View Source
const (
DefaultSlowThreshold = 200 * time.Millisecond
)
Variables ¶
View Source
var (
ErrConcurrency = kerrors.Conflict(ConcurrentUpdateCode, "")
)
Functions ¶
func BuildBooleanFilter ¶
func BuildDateFilter ¶
func BuildDoubleFilter ¶
func BuildFloatFilter ¶
func BuildInt32Filter ¶
func BuildInt64Filter ¶
func BuildNullFilter ¶
func BuildStringFilter ¶
func NewConnStrResolver ¶
func NewConnStrResolver(c *conf.Endpoints, ts saas.TenantStore) data.ConnStrResolver
func NewDbGuardianContext ¶
NewDbGuardianContext flag for database auto creation
func NewDbProvider ¶
func NewDbProvider(cache *DbCache, cs data.ConnStrResolver, d *conf.Data) sgorm.DbProvider
func RegisterCallbacks ¶
RegisterCallbacks register callback into GORM DB
Types ¶
type AuditedModel ¶
type AuditedModel struct { CreatedBy *string UpdatedBy *string CreatedAt time.Time `gorm:"timestamp"` UpdatedAt time.Time `gorm:"timestamp"` }
AuditedModel make Model Auditable, embed `audited.AuditedModel` into your model as anonymous field to make the model auditable
type User struct { gorm.AuditedModel }
func (AuditedModel) GetCreatedBy ¶
func (model AuditedModel) GetCreatedBy() *string
GetCreatedBy get created by
func (AuditedModel) GetUpdatedBy ¶
func (model AuditedModel) GetUpdatedBy() *string
GetUpdatedBy get updated by
func (*AuditedModel) SetCreatedBy ¶
func (model *AuditedModel) SetCreatedBy(createdBy interface{})
SetCreatedBy set created by
func (*AuditedModel) SetUpdatedBy ¶
func (model *AuditedModel) SetUpdatedBy(updatedBy interface{})
SetUpdatedBy set updated by
type BuildDetailScope ¶
type BuildFilterScope ¶
type BuildPageScope ¶
type BuildSortScope ¶
type DbCache ¶
type DbCache struct { *saas.Cache[string, *sgorm.DbWrap] // contains filtered or unexported fields }
func NewDbCache ¶
NewDbCache create a shared gorm.Db cache by dsn
type DbProviderFunc ¶
type DefaultSorting ¶
type DefaultSorting interface {
DefaultSorting() []string
}
type Repo ¶
type Repo[TEntity any, TKey any, TQuery any] struct { DbProvider sgorm.DbProvider Eventbus *eventbus.EventBus // contains filtered or unexported fields }
func (*Repo[TEntity, TKey, TQuery]) BatchCreate ¶
Click to show internal directories.
Click to hide internal directories.