Provided by: libdbix-class-tree-perl_0.03003-2_all
NAME
DBIx::Class::Tree::AdjacencyList::Ordered - Glue DBIx::Class::Ordered and DBIx::Class::Tree::AdjacencyList together.
SYNOPSIS
Create a table for your tree data. CREATE TABLE items ( item_id INTEGER PRIMARY KEY AUTOINCREMENT, parent_id INTEGER NOT NULL DEFAULT 0, position INTEGER NOT NULL, name TEXT NOT NULL ); In your Schema or DB class add Tree::AdjacencyList::Ordered to the front of the component list. __PACKAGE__->load_components(qw( Tree::AdjacencyList::Ordered ... )); Specify the column that contains the parent ID and position of each row. package My::Employee; __PACKAGE__->position_column('position'); __PACKAGE__->parent_column('parent_id'); This module provides a few extra methods beyond what DBIx::Class::Ordered and DBIx::Class::Tree::AdjacencyList already provide. my $parent = $item->parent(); $item->parent( $parent_obj ); $item->parent( $parent_id ); my $children_rs = $item->children(); my @children = $item->children(); $parent->append_child( $child ); $parent->prepend_child( $child ); $this->attach_before( $that ); $this->attach_after( $that );
DESCRIPTION
This module provides methods for working with adjacency lists and ordered rows. All of the methods that DBIx::Class::Ordered and DBIx::Class::Tree::AdjacencyList provide are available with this module.
METHODS
parent_column __PACKAGE__->parent_column('parent_id'); Works the same as AdjacencyList's parent_column() method, but it declares the children() has many relationship to be ordered by the position column. parent my $parent = $item->parent(); $item->parent( $parent_obj ); $item->parent( $parent_id ); This method overrides AdjacencyList's parent() method but modifies it so that the object is moved to the last position, then the parent is changed, and then it is moved to the last position of the new list, thus maintaining the intergrity of the ordered lists. children my $children_rs = $item->children(); my @children = $item->children(); This method works just like it does in the DBIx::Class::Tree::AdjacencyList module except it orders the children by there position. append_child $parent->append_child( $child ); Sets the child to have the specified parent and moves the child to the last position. prepend_child $parent->prepend_child( $child ); Sets the child to have the specified parent and moves the child to the first position. attach_before $this->attach_before( $that ); Attaches the object at the position just before the calling object's position. attach_after $this->attach_after( $that ); Attaches the object at the position just after the calling object's position.
INHERITED METHODS
DBIx::Class::Ordered • siblings • first_sibling • last_sibling • previous_sibling • next_sibling • move_previous • move_next • move_first • move_last • move_to • insert • delete DBIx::Class::Tree::AdjacencyList • parent_column • parent • attach_child • siblings • attach_sibling DBIx::Class • mk_classdata • component_base_class DBIx::Class::Componentised • inject_base • load_components • load_own_components Class::Data::Accessor • mk_classaccessor
AUTHOR
Aran Clary Deltac <bluefeet@cpan.org>
LICENSE
You may distribute this code under the same terms as Perl itself. perl v5.36.0 2023-02DBIx::Class::Tree::AdjacencyList::Ordered(3pm)