prisma-ltree
PostgreSQL ltree extension for Prisma 8
PostgreSQL ltree stores hierarchical tree data. This extension pack adds typed codecs, query operators, and a baseline migration so you can query that data from Prisma 8 without raw SQL.
Author your contract in either lane. Both emit the same compiled result:
- PSL:
contract.prismawithltree.Ltree()andltree.LtreeArray() - TypeScript:
contract.tswithdefineContractandltree()/ltreeArray()
See Author ltree columns for side-by-side examples. The Get started guide covers install, runtime wiring, migrations, and your first queries.
Add a GiST index on path columns so ancestor, descendant, and pattern queries can use an index.
The ltree type
The PostgreSQL ltree type stores dot-separated path labels (e.g. Top.Science.Astronomy). It fits org hierarchies, category trees, taxonomies, and any model where ancestor or descendant queries matter.
Query operations
- Hierarchy operators: ancestor and descendant checks
- Pattern matching operators:
lqueryandltxtquerypatterns - Lowest common ancestor: shared ancestor of paths, including
ltree[]columns