Skip to content

Commit dcebf8e

Browse files
committed
Adding graph docs
1 parent 2cb36a3 commit dcebf8e

File tree

7 files changed

+460
-8
lines changed

7 files changed

+460
-8
lines changed

arangoasync/graph.py

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,15 @@ def name(self) -> str:
6464
"""Name of the graph."""
6565
return self._name
6666

67+
@property
68+
def db_name(self) -> str:
69+
"""Return the name of the current database.
70+
71+
Returns:
72+
str: Database name.
73+
"""
74+
return self._executor.db_name
75+
6776
@property
6877
def serializer(self) -> Serializer[Json]:
6978
"""Return the serializer."""
@@ -686,16 +695,16 @@ def response_handler(resp: Response) -> EdgeCollection[T, U, V]:
686695
async def delete_edge_definition(
687696
self,
688697
name: str,
689-
purge: bool = False,
698+
drop_collections: Optional[bool] = None,
690699
wait_for_sync: Optional[bool] = None,
691700
) -> None:
692701
"""Delete an edge definition from the graph.
693702
694703
Args:
695704
name (str): Edge collection name.
696-
purge (bool): If set to `True`, the edge definition is not just removed
697-
from the graph but the edge collection is also deleted completely
698-
from the database.
705+
drop_collections (bool | None): If set to `True`, the edge definition is not
706+
just removed from the graph but the edge collection is also deleted
707+
completely from the database.
699708
wait_for_sync (bool | None): If set to `True`, the operation waits for
700709
changes to be synced to disk before returning.
701710
@@ -705,7 +714,9 @@ async def delete_edge_definition(
705714
References:
706715
- `remove-an-edge-definition <https://docs.arangodb.com/stable/develop/http-api/graphs/named-graphs/#remove-an-edge-definition>`__
707716
""" # noqa: E501
708-
params: Params = {"dropCollections": purge}
717+
params: Params = {}
718+
if drop_collections is not None:
719+
params["dropCollections"] = drop_collections
709720
if wait_for_sync is not None:
710721
params["waitForSync"] = wait_for_sync
711722

docs/collection.rst

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,10 @@ by its name which must consist only of hyphen, underscore and alphanumeric
66
characters. There are three types of collections in python-arango:
77

88
* **Standard Collection:** contains regular documents.
9-
* **Vertex Collection:** contains vertex documents for graphs (not supported yet).
10-
* **Edge Collection:** contains edge documents for graphs (not supported yet).
9+
* **Vertex Collection:** contains vertex documents for graphs. See
10+
:ref:`here <vertex-collections>` for more details.
11+
* **Edge Collection:** contains edge documents for graphs. See
12+
:ref:`here <edge-collections>` for more details.
1113

1214

1315
Here is an example showing how you can manage standard collections:

docs/document.rst

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,26 @@ collection:
4242
"friends": ["robin", "gordon"]
4343
}
4444
45+
.. _edge-documents:
46+
47+
**Edge documents (edges)** are similar to standard documents but with two
48+
additional required fields ``_from`` and ``_to``. Values of these fields must
49+
be the handles of "from" and "to" vertex documents linked by the edge document
50+
in question (see :doc:`graph` for details). Edge documents are contained in
51+
:ref:`edge collections <edge-collections>`. Here is an example of a valid edge
52+
document in "friends" edge collection:
53+
54+
.. code-block:: python
55+
56+
{
57+
"_id": "friends/001",
58+
"_key": "001",
59+
"_rev": "_Wm3d4le--_",
60+
"_fro"': "students/john",
61+
"_to": "students/jane",
62+
"closeness": 9.5
63+
}
64+
4565
Standard documents are managed via collection API wrapper:
4666

4767
.. code-block:: python

0 commit comments

Comments
 (0)