generics

package
v0.19.921 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 7, 2026 License: AGPL-3.0 Imports: 9 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BatchProcessing

func BatchProcessing[T any](ctx context.Context, batchSize int, query *gorm.DB, processBatch func([]*T) error) error

func IsGormErrRecordNotFound

func IsGormErrRecordNotFound(err error) bool

func MergeJSONBMetadata added in v0.19.903

func MergeJSONBMetadata(db *gorm.DB, model any, id string, field string, metadata map[string]any) error

MergeJSONBMetadata reads a JSONB column's "metadata" key, merges the provided key-value pairs, and writes the column back. The model must be a pointer to a GORM model (e.g. &app.QueueSignal{}).

func SetJSONBMetadataKey added in v0.19.903

func SetJSONBMetadataKey(field, key string, value any) func(*gorm.DB) *gorm.DB

SetJSONBMetadataKey returns a GORM scope that atomically sets a single key inside the metadata sub-object of a JSONB column via jsonb_set. Executes the update as part of the scope — chain .Where() calls before .Scopes().

Example:

db.Model(&app.RunnerProcess{}).
    Where("composite_status::jsonb ->> 'status' = ?", "active").
    Scopes(generics.SetJSONBMetadataKey("composite_status", "shutdown_requested", true))

func TemporalDoNotRetry

func TemporalDoNotRetry(err error, args ...string) error

func TemporalGormError

func TemporalGormError(err error, args ...string) error

func ToHstore

func ToHstore(val map[string]string) pgtype.Hstore

func ToJSON

func ToJSON(val string) []byte

func ToPtrStringMap

func ToPtrStringMap(val map[string]string) map[string]*string

func ToStringMap

func ToStringMap(val pgtype.Hstore) map[string]string

func ToStringMapAny

func ToStringMapAny(val pgtype.Hstore) map[string]any

func WhereJSONBStatusIn added in v0.19.903

func WhereJSONBStatusIn(field string, statuses ...string) func(*gorm.DB) *gorm.DB

WhereJSONBStatusIn returns a GORM scope that filters rows where the "status" key inside a JSONB column matches one of the provided values.

Example:

db.Model(&app.RunnerProcess{}).
    Scopes(generics.WhereJSONBStatusIn("composite_status", "active", "offline")).
    Find(&results)

Types

type JSONBQuerier

type JSONBQuerier struct {
	*gorm.DB
}

JSONBQuerier helps build JSONB queries

func NewJSONBQuery

func NewJSONBQuery(db *gorm.DB) *JSONBQuerier

NewJSONBQuery creates a new JSONB query helper

func (*JSONBQuerier) WhereJSON

func (jq *JSONBQuerier) WhereJSON(queryArgs JSONBQuery) *gorm.DB

WhereJSON adds a WHERE condition for JSONB field

func (*JSONBQuerier) WhereJSONPath

func (jq *JSONBQuerier) WhereJSONPath(field string, path []string, operator string, value interface{}) *gorm.DB

WhereJSONPath queries nested JSON paths

type JSONBQuery

type JSONBQuery struct {
	Operator string
	Field    string
	Path     string
	Value    any
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL