Documentation
¶
Index ¶
- func FindMatch[T any](in []T, pred func(T) bool) (T, bool)
- func Preload(database *gorm.DB, filts map[string]bool) *gorm.DB
- func PreloadAll(database *gorm.DB, names ...string) *gorm.DB
- func ScopeBySource(query *gorm.DB, joinTable, objectFK, tool string) *gorm.DB
- func ToPBs[O pbConvertible[P], P any](ctx context.Context, in []O) ([]*P, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FindMatch ¶
FindMatch returns the first element of in for which pred is true, and whether one was found. It is the generic form of the per-domain "find the matching row in this slice" helpers (identity/absorbable/same-host lookups) so they need not each re-spell the loop.
func Preload ¶
Preload loads a database with the base clause.Associations preload plus every association named with a true value in filts (a false entry is skipped, so callers can gate a preload on a request flag). It is the map-driven form used when the set of associations is conditional; PreloadAll is the plainer variadic form for the unconditional case.
func PreloadAll ¶
PreloadAll loads a database with the base clause.Associations preload plus each named association, unconditionally. It is the single place association preloading is expressed, so the per-domain servers do not each re-implement the clause.Associations + range loop.
func ScopeBySource ¶
ScopeBySource restricts a query to the objects contributed by the named tool, via that object's provenance m2m join (e.g. "host_sources"/"host_id"). An empty tool is a no-op, so callers can thread a request's Source filter through unconditionally. It is the one-liner wrapper the per-domain servers share instead of each repeating the same Scopes(...) block.
Types ¶
This section is empty.