Bark
GitHub
  • Introduction
  • Getting started
  • Client Extension API reference
  • Model Reference
  • Changelog
  • Acknowledgement
Powered by GitBook
On this page
  • Supported Prisma version
  • Minimum required model
  • path
  • depth
  • numchild
Edit on GitHub

Model Reference

Required fields for the extension and further explanation what each field is trying to achieve.

PreviousClient Extension API referenceNextAcknowledgement

Last updated 1 year ago

Supported Prisma version

If your Prisma version below 5.0.0 consider upgrade to this version.

Minimum required model

model node {
    id       Int    @id @default(autoincrement())
    path     String @unique
    depth    Int
    numchild Int    @default(0)

    @@index([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 where it's allowed, such as in the case of PostgreSQL or MySQL.

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.

numchild

type: Int flags: @default(0)

Adapted from

An integer that stores the number of children of a given node. Just like , 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 will return nothing without running any database queries when the numchild is 0.

Adapted from

Prisma Release Notes.
native type
@db.VarChar(255)
django-treebeard
django-treebeard
findChildren
depth