module Sequel::Plugins::Tree

The tree plugin adds additional associations and methods that allow you to treat a Model as a tree.

A column for holding the parent key is required and is :parent_id by default.

This may be overridden by passing column name via :key.

Optionally, a column to control order of nodes returned can be specified by passing column name via :order.

If you pass true for the :single_root option, the class will ensure there is only ever one root in the tree.

Examples:

class Node < Sequel::Model
  plugin :tree
end

class Node < Sequel::Model
  plugin :tree, key: :parentid, order: :position
end