Skip to content

models.traversible

NodeList Objects

1
class NodeList()

Helper class that helps with iterating nested models

add

1
 | add(node_class: Type["RelationMixin"], relation_name: str = None, parent_node: "Node" = None) -> "Node"

Adds new Node or returns the existing one

Arguments:

  • node_class: Model in current node :type node_class: ormar.models.metaclass.ModelMetaclass
  • relation_name: name of the current relation :type relation_name: str
  • parent_node: parent node :type parent_node: Optional[Node]

Returns:

returns new or already existing node :rtype: Node

find

1
 | find(node_class: Type["RelationMixin"], relation_name: Optional[str] = None, parent_node: "Node" = None) -> Optional["Node"]

Searches for existing node with given parameters

Arguments:

  • node_class: Model in current node :type node_class: ormar.models.metaclass.ModelMetaclass
  • relation_name: name of the current relation :type relation_name: str
  • parent_node: parent node :type parent_node: Optional[Node]

Returns:

returns already existing node or None :rtype: Optional[Node]

Node Objects

1
class Node()

visited

1
 | visited(relation_name: str) -> bool

Checks if given relation was already visited.

Relation was visited if it's name is in current node children.

Relation was visited if one of the parent node had the same Model class

Arguments:

  • relation_name: name of relation :type relation_name: str

Returns:

result of the check :rtype: bool