|
| 1 | +Views |
| 2 | +----- |
| 3 | + |
| 4 | +All types of views are supported. . For more information on **view** |
| 5 | +management, refer to `ArangoDB Manual`_. |
| 6 | + |
| 7 | +.. _ArangoDB Manual: https://docs.arangodb.com |
| 8 | + |
| 9 | +**Example:** |
| 10 | + |
| 11 | +.. code-block:: python |
| 12 | +
|
| 13 | + from arangoasync import ArangoClient |
| 14 | + from arangoasync.auth import Auth |
| 15 | +
|
| 16 | + # Initialize the client for ArangoDB. |
| 17 | + async with ArangoClient(hosts="http://localhost:8529") as client: |
| 18 | + auth = Auth(username="root", password="passwd") |
| 19 | +
|
| 20 | + # Connect to "test" database as root user. |
| 21 | + db = await client.db("test", auth=auth) |
| 22 | +
|
| 23 | + # Retrieve list of views. |
| 24 | + await db.views() |
| 25 | +
|
| 26 | + # Create a view. |
| 27 | + await db.create_view( |
| 28 | + name="foo", |
| 29 | + view_type="arangosearch", |
| 30 | + properties={ |
| 31 | + "cleanupIntervalStep": 0, |
| 32 | + "consolidationIntervalMsec": 0 |
| 33 | + } |
| 34 | + ) |
| 35 | +
|
| 36 | + # Rename a view (not supported in cluster deployments). |
| 37 | + await db.rename_view("foo", "bar") |
| 38 | +
|
| 39 | + # Retrieve view properties. |
| 40 | + await db.view("bar") |
| 41 | +
|
| 42 | + # Retrieve view summary. |
| 43 | + await db.view_info("bar") |
| 44 | +
|
| 45 | + # Partially update view properties. |
| 46 | + await db.update_view( |
| 47 | + name="bar", |
| 48 | + properties={ |
| 49 | + "cleanupIntervalStep": 1000, |
| 50 | + "consolidationIntervalMsec": 200 |
| 51 | + } |
| 52 | + ) |
| 53 | +
|
| 54 | + # Replace view properties. Unspecified ones are reset to default. |
| 55 | + await db.replace_view( |
| 56 | + name="bar", |
| 57 | + properties={"cleanupIntervalStep": 2000} |
| 58 | + ) |
| 59 | +
|
| 60 | + # Delete a view. |
| 61 | + await db.delete_view("bar") |
| 62 | +
|
| 63 | +For more information on the content of view **properties**, |
| 64 | +see `Search Alias Views`_ and `Arangosearch Views`_. |
| 65 | + |
| 66 | +.. _Search Alias Views: https://docs.arangodb.com/stable/develop/http-api/views/search-alias-views/ |
| 67 | +.. _Arangosearch Views: https://docs.arangodb.com/stable/develop/http-api/views/arangosearch-views/ |
| 68 | + |
| 69 | +Refer to :class:`arangoasync.database.StandardDatabase` class for API specification. |
0 commit comments