traversible
Node
Source code in ormar\models\traversible.py
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 |
|
visited(relation_name)
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
Parameters:
Name | Type | Description | Default |
---|---|---|---|
relation_name |
str
|
name of relation |
required |
Returns:
Type | Description |
---|---|
bool
|
result of the check |
Source code in ormar\models\traversible.py
98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 |
|
NodeList
Helper class that helps with iterating nested models
Source code in ormar\models\traversible.py
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
|
add(node_class, relation_name=None, parent_node=None)
Adds new Node or returns the existing one
Parameters:
Name | Type | Description | Default |
---|---|---|---|
node_class |
Type[RelationMixin]
|
Model in current node |
required |
relation_name |
Optional[str]
|
name of the current relation |
None
|
parent_node |
Optional[Node]
|
parent node |
None
|
Returns:
Type | Description |
---|---|
Node
|
returns new or already existing node |
Source code in ormar\models\traversible.py
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
|
find(node_class, relation_name=None, parent_node=None)
Searches for existing node with given parameters
Parameters:
Name | Type | Description | Default |
---|---|---|---|
node_class |
Type[RelationMixin]
|
Model in current node |
required |
relation_name |
Optional[str]
|
name of the current relation |
None
|
parent_node |
Optional[Node]
|
parent node |
None
|
Returns:
Type | Description |
---|---|
Optional[Node]
|
returns already existing node or None |
Source code in ormar\models\traversible.py
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
|