I'm looking for an API to perform a bulk delete in ArangoDB. How could i do it?
I have gone through the below link... but i felt it is too tedious. https://docs.arangodb.com/3.11/develop/http/batch-requests/
Actually i'm looking for something simpler way like bulk import syntax (pasted below for your reference)
curl --data-binary @- -X POST --dump - "http://localhost:8529/_api/import?collection=test&createCollection=true" [ "firstName", "lastName", "age", "gender" ] [ "Joe", "Public", 42, "male" ] [ "Jane", "Doe", 31, "female" ]
Please help me in this regard.
Thanks in advance
You can easily delete a bunch of items from a collections using AQL like this: (like you would execute it in arangosh, which in term will use the REST api)
db._query(`FOR item IN test FILTER item._key IN @listToDelete REMOVE item IN test`,
{listToDelete: ['key1', 'key2']})
as I did with the '_key' attribute you have to specify an attribute to match for agains the array in the bind values.
Using ngrep or wireshark you can easily find out howto send such an AQL query via the REST interface on your own without drivers:
POST /_db/_system/_api/cursor HTTP/1.1
Host: 127.0.0.1
Connection: Keep-Alive
User-Agent: ArangoDB
Accept-Encoding: deflate
Authorization: Basic xxxxx
Content-Length: 133
{"query":"FOR item IN test FILTER item._key IN @listToDelete REMOVE item IN test","count":false,"bindVars":{"listToDelete":["840"]}}
T 127.0.0.1:8529 -> 127.0.0.1:39125 [AP]
HTTP/1.1 201 Created
Server: ArangoDB
Connection: Keep-Alive
Content-Type: application/json; charset=utf-8
Content-Length: 223
{"result":[],"hasMore":false,"cached":false,"extra":{"stats":{"writesExecuted":0,"writesIgnored":0,"scannedFull":0,"scannedIndex":0,"filtered":0,"executionTime":2.739429473876953e-4},"warnings":[]},"error":false,"code":201}