Skip to main content

Delete documents

ArangoDB's official AQL docs for REMOVE can be found here

Remove document by key

  1. Remove an existing document

    remove "foo-bar" IN scratch RETURN OLD
  2. You should see the following results:

    [
    {
    "_key": "foo-bar",
    "_id": "scratch/foo-bar",
    "_rev": "_gdofeje--A",
    "field1": "foo",
    "field2": "bar"
    }
    ]
  3. Running the query again should return an error

Delete documents in a collection based on filter

  1. Remove all documents where field1 = 'field1-updated'

    for doc in scratch
    filter doc.field1=='foo'
    remove doc in scratch
  2. You should see the following result:

        []
  3. You can confirm that the query worked correctly by running:

    for doc in scratch
    filter doc.field1 == 'foo'
    return doc
  4. You should see the following result:

    ```json
    []
    ```
     
    Help us improve

    Anything unclear or buggy in this tutorial? Provide Feedback