2016-05-17 159 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