Postgres: Filter by Hierarchical ltree Data
Introduction
Comparison operators on columns with ltree
, lquery
or ltxtquery
types are supported.
Please submit a feature request via GitHub if you want support for more functions.
For more details on ltree
operators and Postgres equivalents, refer to the
API reference.
_ancestor
Select ancestors of an ltree argument
GraphiQL
xxxxxxxxxx
query {
tree (
where: {path: {_ancestor: "Tree.Collections.Pictures.Astronomy.Astronauts"}}
) {
path
}
}
Query Variables
Request Headers
1
{
"data": {
"tree": [
{
"path": "Tree"
},
{
"path": "Tree.Collections"
},
{
"path": "Tree.Collections.Pictures"
},
{
"path": "Tree.Collections.Pictures.Astronomy"
},
{
"path": "Tree.Collections.Pictures.Astronomy.Astronauts"
}
]
}
}
No Schema Available
_ancestor_any
GraphiQL
xxxxxxxxxx
query {
test(
where: {
path: {
_ancestor_any: [
"Top.Collections.Pictures.Astronomy"
"Top.Science.Astronomy"
]
}
}
) {
path
}
}
Query Variables
Request Headers
1
x
{
"data": {
"test": [
{
"path": "Top"
},
{
"path": "Top.Science"
},
{
"path": "Top.Science.Astronomy"
},
{
"path": "Top.Collections"
},
{
"path": "Top.Collections.Pictures"
},
{
"path": "Top.Collections.Pictures.Astronomy"
}
]
}
}
No Schema Available
_matches
Match any label path containing the node Astronomy
.
GraphiQL
xxxxxxxxxx
query {
test(where: { path: { _matches: "*.Astronomy.*" } }) {
path
}
}
Query Variables
Request Headers
1
xxxxxxxxxx
{
"data": {
"test": [
{
"path": "Top.Science.Astronomy"
},
{
"path": "Top.Science.Astronomy.Astrophysics"
},
{
"path": "Top.Science.Astronomy.Cosmology"
},
{
"path": "Top.Collections.Pictures.Astronomy"
},
{
"path": "Top.Collections.Pictures.Astronomy.Stars"
},
{
"path": "Top.Collections.Pictures.Astronomy.Galaxies"
},
{
"path": "Top.Collections.Pictures.Astronomy.Astronauts"
}
]
}
}
No Schema Available
_matches_any
Select ltree paths matching any lquery regex in an array
GraphiQL
xxxxxxxxxx
query {
tree (
where: {path: {_matches_any: ["*.Pictures.*", "*.Hobbies.*"]}}
) {
path
}
}
Query Variables
Request Headers
1
xxxxxxxxxx
{
"data": {
"tree": [
{
"path": "Tree.Hobbies"
},
{
"path": "Tree.Hobbies.Amateurs_Astronomy"
},
{
"path": "Tree.Collections.Pictures"
},
{
"path": "Tree.Collections.Pictures.Astronomy"
},
{
"path": "Tree.Collections.Pictures.Astronomy.Stars"
},
{
"path": "Tree.Collections.Pictures.Astronomy.Galaxies"
},
{
"path": "Tree.Collections.Pictures.Astronomy.Astronauts"
}
]
}
}
No Schema Available
_descendant
GraphiQL
xxxxxxxxxx
query {
test(where: { path: { _descendant: "Top.Collections.Pictures.Astronomy" } }) {
path
}
}
Query Variables
Request Headers
1
xxxxxxxxxx
{
"data": {
"test": [
{
"path": "Top.Collections.Pictures.Astronomy"
},
{
"path": "Top.Collections.Pictures.Astronomy.Stars"
},
{
"path": "Top.Collections.Pictures.Astronomy.Galaxies"
},
{
"path": "Top.Collections.Pictures.Astronomy.Astronauts"
}
]
}
}
No Schema Available
_descendant_any
GraphiQL
xxxxxxxxxx
query {
test(where: { path: { _descendant_any: ["Top.Collections.Pictures.Astronomy", "Top.Science.Astronomy"] } }) {
path
}
Query Variables
Request Headers
1
xxxxxxxxxx
{
"data": {
"test": [
{
"path": "Top.Science.Astronomy"
},
{
"path": "Top.Science.Astronomy.Astrophysics"
},
{
"path": "Top.Science.Astronomy.Cosmology"
},
{
"path": "Top.Collections.Pictures.Astronomy"
},
{
"path": "Top.Collections.Pictures.Astronomy.Stars"
},
{
"path": "Top.Collections.Pictures.Astronomy.Galaxies"
},
{
"path": "Top.Collections.Pictures.Astronomy.Astronauts"
}
]
}
No Schema Available
_matches_fulltext
Match any label path containing a node containing the substring Astro
.
GraphiQL
xxxxxxxxxx
query {
test(where: { path: { _matches_fulltext: "Astro*%" } }) {
path
}
}
Query Variables
Request Headers
1
xxxxxxxxxx
{
"data": {
"test": [
{
"path": "Top.Science.Astronomy"
},
{
"path": "Top.Science.Astronomy.Astrophysics"
},
{
"path": "Top.Science.Astronomy.Cosmology"
},
{
"path": "Top.Hobbies.Amateurs_Astronomy"
},
{
"path": "Top.Collections.Pictures.Astronomy"
},
{
"path": "Top.Collections.Pictures.Astronomy.Stars"
},
{
"path": "Top.Collections.Pictures.Astronomy.Galaxies"
},
{
"path": "Top.Collections.Pictures.Astronomy.Astronauts"
}
]
}
}
No Schema Available