Documentation
¶
Overview ¶
Package ltree is the ltree extension: a materialized-path label tree with its own operators. Needs CREATE EXTENSION ltree; the @> and ~ operators are served by a GiST index with gist_ltree_ops.
Index ¶
- Variables
- func AncestorOf(a, b sqlb.Expr[Path]) sqlb.Predicate
- func Concat(a, b sqlb.Expr[Path]) sqlb.Expr[Path]
- func DescendantOf(a, b sqlb.Expr[Path]) sqlb.Predicate
- func Index(p sqlb.Expr[Path], sub string) sqlb.Expr[int32]
- func LCA(paths ...sqlb.Expr[Path]) sqlb.Expr[Path]
- func Lit(path string) sqlb.Expr[Path]
- func MatchesLQuery(path sqlb.Expr[Path], lquery string) sqlb.Predicate
- func MatchesTxtQuery(path sqlb.Expr[Path], q string) sqlb.Predicate
- func NLevel(p sqlb.Expr[Path]) sqlb.Expr[int32]
- func Subltree(p sqlb.Expr[Path], start, end int) sqlb.Expr[Path]
- func Subpath(p sqlb.Expr[Path], offset, length int) sqlb.Expr[Path]
- type Path
Constants ¶
This section is empty.
Variables ¶
var Extension = pg.Extension{Name: "ltree"}
Extension is the ltree extension this package's constructs need, for pg.CreateExtension(Extension), so a library installs what it uses without spelling its name.
var GistOps = pg.NewOpClass[Path]("gist_ltree_ops")
GistOps is ltree's operator class, which serves the ancestor and descendant operators; pg.GiST is its method.
Functions ¶
func AncestorOf ¶
AncestorOf renders a @> b: a is an ancestor of b, or equal.
func DescendantOf ¶
DescendantOf renders a <@ b: a is below b, or equal.
func Lit ¶
Lit renders a bound path with an explicit cast, $n::ltree, so an operator between a column and the parameter resolves without ambiguity.
func MatchesLQuery ¶
MatchesLQuery renders path ~ $n::lquery, the pattern "*.science.*{1,}".
func MatchesTxtQuery ¶
MatchesTxtQuery renders path @ $n::ltxtquery, the boolean label search "science & !astronomy".
func NLevel ¶
NLevel renders nlevel(p), the number of labels in the path. It is the depth of the node, so it orders a subtree by level.