Skip to Content
prisma-ltree

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.prisma with ltree.Ltree() and ltree.LtreeArray()
  • TypeScript: contract.ts with defineContract and ltree() / ltreeArray()

See Author ltree columns for side-by-side examples. The Get started guide covers install, runtime wiring, migrations, and your first queries.

Indexes and sorting

GiST required for ancestor, descendant, and pattern queries: add a GiST index on path columns (@@index([path], type: "gist")). Without it, those filters still run as sequential scans.

B-tree comparison and orderBy come from the codec traits equality and order on pg/ltree@1. This pack does not add < / > methods. See Sort and compare paths.

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

On this page