Skip to content

Files

Latest commit

 

History

History
62 lines (45 loc) · 2.06 KB

simple.rst

File metadata and controls

62 lines (45 loc) · 2.06 KB

Simple Queries

Here is an example of using ArangoDB's simply queries:

.. testcode::

    from arango import ArangoClient

    # Initialize the ArangoDB client.
    client = ArangoClient()

    # Connect to "test" database as root user.
    db = client.db('test', username='root', password='passwd')

    # Get the API wrapper for "students" collection.
    students = db.collection('students')

    # Get the IDs of all documents in the collection.
    students.ids()

    # Get the keys of all documents in the collection.
    students.keys()

    # Get all documents in the collection with skip and limit.
    students.all(skip=0, limit=100)

    # Find documents that match the given filters.
    students.find({'name': 'Mary'}, skip=0, limit=100)

    # Get documents from the collection by IDs or keys.
    students.get_many(['id1', 'id2', 'key1'])

    # Get a random document from the collection.
    students.random()

    # Update all documents that match the given filters.
    students.update_match({'name': 'Kim'}, {'age': 20})

    # Replace all documents that match the given filters.
    students.replace_match({'name': 'Ben'}, {'age': 20})

    # Delete all documents that match the given filters.
    students.delete_match({'name': 'John'})

Here are all simple query (and other utility) methods available: