Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func WithLabels ¶
WithLabels returns a GORM scope that filters rows where the JSONB column contains all the specified key-value pairs (PostgreSQL @> containment). A value of "*" is treated as a wildcard — it matches any value for that key (uses jsonb_exists() to check key existence). Returns a no-op scope if lbls is nil or empty.
Types ¶
type Labeled ¶
type Labeled struct {
Labels Labels `json:"labels,omitzero" gorm:"default null" temporaljson:"labels,omitzero,omitempty"`
}
Labeled is an embeddable struct for any GORM model that supports labels. Embed it to get a consistent JSONB labels column with standard tags.
type Labels ¶
Labels defines a custom type for map[string]string that works with JSONB in GORM.
func ParseLabelsQuery ¶
ParseLabelsQuery parses a comma-separated "key:value" string into Labels. Returns nil for empty input. Entries without a separator are treated as wildcard key-only filters (value set to "*"). Supports both ":" and "=" as key-value separators. Splits on the first separator only, so values may contain colons or equals. A value of "*" means "match any value for this key" (wildcard).
func (Labels) GormDataType ¶
GormDataType returns the GORM data type for this field.
func (*Labels) Merge ¶
Merge adds all key-value pairs from other into the receiver, overwriting existing keys.
func (*Labels) RemoveKeys ¶
RemoveKeys removes the specified keys from the labels.