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/HttpBatchRequest/index.html
Actually i'm looking for some thing 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
答案 0 :(得分:0)
您可以使用AQL轻松地从集合中删除一堆项目:(就像您将在arangosh中执行它,在术语中将使用REST api)
db._query(`FOR item IN test FILTER item._key IN @listToDelete REMOVE item IN test`,
{listToDelete: ['key1', 'key2']})
就像我对'_key'属性所做的那样,你必须指定一个属性来匹配绑定值中的数组。
使用ngrep或wireshark,您可以轻松找到如何通过REST接口自行发送此类AQL查询而无需驱动程序:
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}