internal

package
v0.32.0 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2025 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AllColsInList added in v0.29.0

func AllColsInList(cols []string, lists ...[]string) bool

Check if any one of the lists contains all the columns

func Delete added in v0.32.0

func Delete(from, to int) deleteRule

func EditCallback added in v0.32.0

func EditCallback(rule EditRule, callbacks ...func(start, end int, before, after string) error) callbackRule

func EditString added in v0.32.0

func EditString(s string, rules ...EditRule) (string, error)

func EditStringSegment added in v0.32.0

func EditStringSegment(s string, from, to int, rules ...EditRule) (string, error)

func FilterNonZero added in v0.15.0

func FilterNonZero[T comparable](s []T) []T

func FirstNonEmpty added in v0.15.0

func FirstNonEmpty[T comparable, Ts ~[]T](slice Ts) T

func GetColumnValues added in v0.3.1

func GetColumnValues[T any](mapping mappings.Mapping, filter []string, objs ...T) ([]string, [][]bob.Expression, error)

Get the values for non generated columns

func InList added in v0.29.0

func InList[T comparable](s []T, val T) bool

func Insert added in v0.32.0

func Insert(pos int, content string) insertRule

func InsertFromFunc added in v0.32.0

func InsertFromFunc(pos int, content func() string) insertRule

func MappingCols added in v0.23.0

func MappingCols(m mappings.Mapping, table ...string) orm.Columns

func RandInt added in v0.21.0

func RandInt() int64

func RemoveDuplicates added in v0.29.0

func RemoveDuplicates[T comparable, Ts ~[]T](slice Ts) Ts

func Replace added in v0.32.0

func Replace(from, to int, content string) replaceRule

func ReplaceFromFunc added in v0.32.0

func ReplaceFromFunc(from, to int, content func() string) replaceRule

func SliceMatch added in v0.29.0

func SliceMatch[T comparable, Ts ~[]T](a, b Ts) bool

func ToAnySlice added in v0.15.0

func ToAnySlice[T any, Ts ~[]T](slice Ts) []any

Types

type AfterPreloader added in v0.13.0

type AfterPreloader struct {
	// contains filtered or unexported fields
}

AfterPreloader is embedded in a Preloader to chain loading whenever a preloaded object is scanned, it should be collected with the Collect method The loading functions should be added with AppendLoader later, when this object is called like any other bob.Loader, it calls the appended loaders with the collected objects

func NewAfterPreloader added in v0.13.0

func NewAfterPreloader[T any, Ts ~[]T]() *AfterPreloader

NewAfterPreloader returns a new AfterPreloader based on the given types

func (*AfterPreloader) AppendLoader added in v0.13.0

func (a *AfterPreloader) AppendLoader(fs ...bob.Loader)

func (*AfterPreloader) Collect added in v0.13.0

func (a *AfterPreloader) Collect(v any) error

func (*AfterPreloader) Load added in v0.13.0

func (a *AfterPreloader) Load(ctx context.Context, exec bob.Executor, _ any) error

type EditRule added in v0.32.0

type EditRule interface {
	// contains filtered or unexported methods
}

func RecordPoints added in v0.32.0

func RecordPoints(oldStart, oldEnd int, callbacks ...func(start, end int) error) []EditRule

type Loader added in v0.19.0

type Loader[Q loadable] func(ctx context.Context, exec bob.Executor, retrieved any) error

Loader builds a query mod that makes an extra query after the object is retrieved it can be used to prevent N+1 queries by loading relationships in batches

func (Loader[Q]) Apply added in v0.19.0

func (l Loader[Q]) Apply(q Q)

Apply satisfies the bob.Mod[Q] interface

func (Loader[Q]) Load added in v0.19.0

func (l Loader[Q]) Load(ctx context.Context, exec bob.Executor, retrieved any) error

Load is called after the original object is retrieved

func (Loader[Q]) ModifyPreloadSettings added in v0.19.0

func (l Loader[Q]) ModifyPreloadSettings(s *PreloadSettings[Q])

modifyPreloader makes a Loader also work as a mod for a Preloader

type OutOfBoundsError added in v0.32.0

type OutOfBoundsError int

func (OutOfBoundsError) Error added in v0.32.0

func (e OutOfBoundsError) Error() string

func (OutOfBoundsError) Is added in v0.32.0

func (e OutOfBoundsError) Is(target error) bool

type PreloadAs added in v0.27.0

type PreloadAs[Q loadable] string

func (PreloadAs[Q]) ModifyPreloadSettings added in v0.27.0

func (o PreloadAs[Q]) ModifyPreloadSettings(el *PreloadSettings[Q])

type PreloadExcept added in v0.20.0

type PreloadExcept[Q loadable] []string

func (PreloadExcept[Q]) ModifyPreloadSettings added in v0.20.0

func (e PreloadExcept[Q]) ModifyPreloadSettings(el *PreloadSettings[Q])

type PreloadOnly added in v0.20.0

type PreloadOnly[Q loadable] []string

func (PreloadOnly[Q]) ModifyPreloadSettings added in v0.20.0

func (o PreloadOnly[Q]) ModifyPreloadSettings(el *PreloadSettings[Q])

type PreloadOption added in v0.19.0

type PreloadOption[Q loadable] interface {
	ModifyPreloadSettings(*PreloadSettings[Q])
}

type PreloadSettings added in v0.19.0

type PreloadSettings[Q loadable] struct {
	Columns     []string
	SubLoaders  []Preloader[Q]
	ExtraLoader *AfterPreloader
	Mods        [][]preloadfilter
	Alias       string
}

func NewPreloadSettings added in v0.19.0

func NewPreloadSettings[T any, Ts ~[]T, Q loadable](cols []string) PreloadSettings[Q]

type PreloadWhere added in v0.20.0

type PreloadWhere[Q loadable] []preloadfilter

func (PreloadWhere[Q]) ModifyPreloadSettings added in v0.20.0

func (filters PreloadWhere[Q]) ModifyPreloadSettings(el *PreloadSettings[Q])

type Preloadable added in v0.19.0

type Preloadable interface {
	Preload(name string, rel any) error
}

type Preloader added in v0.19.0

type Preloader[Q loadable] func(parent string) (bob.Mod[Q], scan.MapperMod, []bob.Loader)

Preloader builds a query mod that modifies the original query to retrieve related fields while it can be used as a queryMod, it does not have any direct effect. if using manually, the ApplyPreload method should be called with the query's context AFTER other mods have been applied

func (Preloader[Q]) Apply added in v0.19.0

func (l Preloader[Q]) Apply(q Q)

Apply satisfies bob.Mod[*dialect.SelectQuery]. 1. It modifies the query to join the preloading table and the extra columns to retrieve 2. It modifies the mapper to scan the new columns. 3. It calls the original object's Preload method with the loaded object

func (Preloader[Q]) ModifyPreloadSettings added in v0.19.0

func (l Preloader[Q]) ModifyPreloadSettings(s *PreloadSettings[Q])

modifyPreloader makes a Loader also work as a mod for a Preloader

type RuleType added in v0.32.0

type RuleType int
const (
	CopyRuleType RuleType = iota
	InsertRuleType
	ReplaceRuleType
	DeleteRuleType
)

func (RuleType) String added in v0.32.0

func (r RuleType) String() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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