Documentation ¶
Index ¶
- func AddNodeByParent(db *sql.DB, id int64, name string, parentID int64) error
- func AddNodeBySibling(db *sql.DB, id int64, name string, siblingID int64) error
- func AddRootNode(db *sql.DB, id int64, name string) error
- func RemoveNodeAndDescendants(db *sql.DB, id int64) error
- func RemoveOneNode(db *sql.DB, id int64) error
- func SetTableName(name string)
- type Node
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddNodeByParent ¶
AddNodeByParent adds a new node with certain parent, new node will be the last child of the parent.
func AddNodeBySibling ¶
AddNodeBySibling add a new node right after sibling
func AddRootNode ¶
AddRootNode adds a new root. There could be more than one root node, and the new root will be the left most one, or AddNodeBySibling should be used to insert a new root after another one.
func RemoveNodeAndDescendants ¶
RemoveNodeAndDescendants removes node and all its descendants -- it removes the whole subtree.
func RemoveOneNode ¶
RemoveOneNode removes one node and move all its descentants 1 level up -- it removes the certain node from the tree only.
Types ¶
type Node ¶
type Node struct { ID int64 Node string ParentID int64 Depth int32 Path []int64 PathName []string NumChildren int32 }
Node detail with path from root to node
func GetChildren ¶
GetChildren returns all immediate children of node
func GetDescendants ¶
GetDescendants returns sub tree of node
func GetNodeDetail ¶
GetNodeDetail with path from root