2016-05-17 87 views
0

我正在尋找一個API來在ArangoDB中執行批量刪除。我怎麼能這樣做?關於arangodb中的批量刪除API

我已經通過下面的鏈接...但我覺得它太乏味了。 https://docs.arangodb.com/HttpBatchRequest/index.html

其實,我在尋找一些東西一樣批量導入的語法更簡單的方法(粘貼下面參考)

捲曲--data二進制@ - -X POST自卸 - 「 http://localhost:8529/_api/import?collection=test&createCollection=true「 [」firstName「,」lastName「,」age「,」gender「] [」Joe「,」Public「,42, 」male「] [」Jane「,」Doe「,31, ]

請在這方面幫助我。

在此先感謝

  • 馬希

回答

0

您可以輕鬆地刪除了一堆使用AQL這樣的收藏項目:(就像你在arangosh執行它,這在短期將使用在REST API)

db._query(`FOR item IN test FILTER item._key IN @listToDelete REMOVE item IN test`, 
      {listToDelete: ['key1', 'key2']}) 

像我一樣用「_key」屬性必須指定一個屬性,以匹配agains在綁定值的數組。

使用ngrepwireshark你可以很容易找到HOWTO通過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} 
+0

謝謝你這麼多dothebart ......它的工作:) – mahi