Documentation
¶
Index ¶
- func AllColsInList(cols []string, lists ...[]string) bool
- func FilterNonZero[T comparable](s []T) []T
- func FirstNonEmpty[T comparable, Ts ~[]T](slice Ts) T
- func GetColumnValues[T any](mapping mappings.Mapping, filter []string, objs ...T) ([]string, [][]bob.Expression, error)
- func InList[T comparable](s []T, val T) bool
- func MappingCols(m mappings.Mapping, table ...string) orm.Columns
- func RandInt() int64
- func RemoveDuplicates[T comparable, Ts ~[]T](slice Ts) Ts
- func SliceMatch[T comparable, Ts ~[]T](a, b Ts) bool
- func ToAnySlice[T any, Ts ~[]T](slice Ts) []any
- type AfterPreloader
- type Loader
- type PreloadAs
- type PreloadExcept
- type PreloadOnly
- type PreloadOption
- type PreloadSettings
- type PreloadWhere
- type Preloadable
- type Preloader
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AllColsInList ¶
Check if any one of the lists contains all the columns
func FilterNonZero ¶
func FilterNonZero[T comparable](s []T) []T
func FirstNonEmpty ¶
func FirstNonEmpty[T comparable, Ts ~[]T](slice Ts) T
func GetColumnValues ¶
func GetColumnValues[T any](mapping mappings.Mapping, filter []string, objs ...T) ([]string, [][]bob.Expression, error)
Get the values for non generated columns
func InList ¶
func InList[T comparable](s []T, val T) bool
func RemoveDuplicates ¶
func RemoveDuplicates[T comparable, Ts ~[]T](slice Ts) Ts
func SliceMatch ¶
func SliceMatch[T comparable, Ts ~[]T](a, b Ts) bool
func ToAnySlice ¶
Types ¶
type AfterPreloader ¶
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 ¶
func NewAfterPreloader[T any, Ts ~[]T]() *AfterPreloader
NewAfterPreloader returns a new AfterPreloader based on the given types
func (*AfterPreloader) AppendLoader ¶
func (a *AfterPreloader) AppendLoader(fs ...bob.Loader)
func (*AfterPreloader) Collect ¶
func (a *AfterPreloader) Collect(v any) error
type Loader ¶
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]) ModifyPreloadSettings ¶
func (l Loader[Q]) ModifyPreloadSettings(s *PreloadSettings[Q])
modifyPreloader makes a Loader also work as a mod for a Preloader
type PreloadAs ¶
type PreloadAs[Q loadable] string
func (PreloadAs[Q]) ModifyPreloadSettings ¶
func (o PreloadAs[Q]) ModifyPreloadSettings(el *PreloadSettings[Q])
type PreloadExcept ¶
type PreloadExcept[Q loadable] []string
func (PreloadExcept[Q]) ModifyPreloadSettings ¶
func (e PreloadExcept[Q]) ModifyPreloadSettings(el *PreloadSettings[Q])
type PreloadOnly ¶
type PreloadOnly[Q loadable] []string
func (PreloadOnly[Q]) ModifyPreloadSettings ¶
func (o PreloadOnly[Q]) ModifyPreloadSettings(el *PreloadSettings[Q])
type PreloadOption ¶
type PreloadOption[Q loadable] interface {
ModifyPreloadSettings(*PreloadSettings[Q])
}
type PreloadSettings ¶
type PreloadSettings[Q loadable] struct {
Columns []string
SubLoaders []Preloader[Q]
ExtraLoader *AfterPreloader
Mods [][]preloadfilter
Alias string
}
func NewPreloadSettings ¶
func NewPreloadSettings[T any, Ts ~[]T, Q loadable](cols []string) PreloadSettings[Q]
type PreloadWhere ¶
type PreloadWhere[Q loadable] []preloadfilter
func (PreloadWhere[Q]) ModifyPreloadSettings ¶
func (filters PreloadWhere[Q]) ModifyPreloadSettings(el *PreloadSettings[Q])
type Preloadable ¶
type Preloader ¶
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 ¶
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 ¶
func (l Preloader[Q]) ModifyPreloadSettings(s *PreloadSettings[Q])
modifyPreloader makes a Loader also work as a mod for a Preloader