Query functions¶
-
get_ancestor_ids(cur, node)¶ Return an iterator that yields the ID of every element while traversing from
nodeto the root node.Parameters: node (Node or int) –
-
get_ancestors(cur, node, sort=True)¶ Return an iterator that yields a
NodeDataobject of every element while traversing fromnodeto the root node.Parameters: - node (Node or int) –
- sort (bool) – Start with closest node and end with root node. (default: True)
-
get_child_ids(cur, node)¶ Return an iterator that yields the ID of every immediate child.
Parameters: node (Node or int) –
-
get_children(cur, node)¶ Return an iterator that yields a
NodeDataobject of every immediate child.Parameters: node (Node or int) –
-
get_children_count(cur, node)¶ Get amount of immediate children.
Parameters: node (Node or int) – Node
-
get_descendant_ids(cur, node)¶ Return an iterator that yields a
NodeDataobject of each element in the nodes subtree. Be careful when converting this iterator to an iterable (like list or set) because it could contain billions of objects.Parameters: node (Node or int) –
-
get_descendants(cur, node)¶ Return an iterator that yields the ID of every element while traversing from
nodeto the root node.Parameters: node (Node or int) –
-
get_node(cur, id)¶ Return
NodeDataobject for givenid. RaisesValueErrorif ID doesn’t exist.Parameters: id (int) – Database ID
-
get_node_at_position(cur, node, position)¶ Return node at
positionin the children ofnode.Parameters: - node (Node or int) –
- position (int) –
-
get_root_node(cur)¶ Return root node. Raise
ValueErrorif root node doesn’t exist.
-
get_tree_size(cur)¶ Return the total amount of tree nodes.