A community developer built prisma-ltree, an extension pack for Prisma Next that adds typed PostgreSQL ltree support. The post explains why ltree outperforms common hierarchy patterns (parent references, text paths, nested sets) for tree-structured data, then walks through a six-step setup: installing the package, registering control and runtime extensions, defining ltree columns in schema, initializing the database, and running typed queries. Key operators covered include isDescendantOf, isAncestorOf, matchesLquery (with lquery wildcard gotchas), and lca (lowest common ancestor). Current limitations include no GiST index declaration in schema — those must be created manually in SQL. Both Prisma Next and prisma-ltree are in Early Access.
Table of contents
Common hierarchy patterns (and their costs)Using ltree with Prisma NextEarly AccessTry it580 Impressions