Model Reference
Required fields for the extension and further explanation what each field is trying to achieve.
Supported Prisma version
If your Prisma version below 5.0.0
consider upgrade to this version. Prisma Release Notes.
Minimum required model
path
path
type: String
flags: @unique
A unique string that stores the materialized path of each node. The string is constructed of base 36 encoded, padded to minimum 4 characters. Which grants 1679615 children per node.
It is recommended to define an index in the schema for path
since almost all methods rely on ordering by path in some ways.
Database type can optionally be mapped to a more performant native type where it's allowed, such as @db.VarChar(255)
in the case of PostgreSQL or MySQL.
depth
depth
type: Int
Integer that stores the depth of the node in the tree. Its main function is to speeds up the database queries by filtering down possible nodes to a given depth. However this comes at the cost of higher complexity when nodes are created or moved around.
Adapted from django-treebeard
numchild
numchild
type: Int
flags: @default(0)
An integer that stores the number of children of a given node. Just like depth
, its main function to speed up queries by storing this value ahead of time so we don't have to run redundant queries if we know it will yield no result. For example findChildren
will return nothing without running any database queries when the numchild
is 0.
Adapted from django-treebeard
Last updated