Documentation
¶
Index ¶
- type GormRepository
- func (r *GormRepository[T]) Clear(ctx context.Context) error
- func (r *GormRepository[T]) Count(ctx context.Context, conditions ...clause.Expression) (int64, error)
- func (r *GormRepository[T]) Delete(ctx context.Context, conditions ...clause.Expression) (int64, error)
- func (r *GormRepository[T]) Get(ctx context.Context, conditions ...clause.Expression) (T, error)
- func (r *GormRepository[T]) List(ctx context.Context, conditions ...clause.Expression) ([]T, error)
- func (r *GormRepository[T]) Upsert(ctx context.Context, rows ...T) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type GormRepository ¶ added in v0.4.0
type GormRepository[T any] struct { // contains filtered or unexported fields }
GormRepository provides typed SQLite operations on the generics API. The handle stays at the base *gorm.DB. Each call derives its chain from it, so reused chains never leak conditions across calls.
func NewGormRepository ¶ added in v0.4.0
func NewGormRepository[T any](database *gorm.DB, keyColumns ...string) *GormRepository[T]
NewGormRepository creates a typed repository on the given handle. keyColumns names the primary key columns for upsert conflict targets, so secondary unique violations surface as duplicates instead of overwrites.
func (*GormRepository[T]) Clear ¶ added in v0.4.0
func (r *GormRepository[T]) Clear(ctx context.Context) error
Clear removes every row. Maintenance and tests own this path. The generics API has no session scope, so the global delete uses the traditional handle with AllowGlobalUpdate. This is the one listed use.
func (*GormRepository[T]) Count ¶ added in v0.4.0
func (r *GormRepository[T]) Count(ctx context.Context, conditions ...clause.Expression) (int64, error)
Count returns the number of rows matching the given conditions.
func (*GormRepository[T]) Delete ¶ added in v0.4.0
func (r *GormRepository[T]) Delete(ctx context.Context, conditions ...clause.Expression) (int64, error)
Delete removes rows matching the given conditions and returns the count.
func (*GormRepository[T]) Get ¶ added in v0.4.0
func (r *GormRepository[T]) Get(ctx context.Context, conditions ...clause.Expression) (T, error)
Get returns the first row matching the given conditions. A miss returns the domain not-found sentinel.
func (*GormRepository[T]) List ¶ added in v0.4.0
func (r *GormRepository[T]) List(ctx context.Context, conditions ...clause.Expression) ([]T, error)
List returns every row matching the given conditions.