简体   繁体   English

关于arangodb中的批量删除API

[英]Regarding bulk delete API in arangodb

I'm looking for an API to perform a bulk delete in ArangoDB. 我正在寻找一个API在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 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" ] curl --data-binary @--X POST --dump-“ http:// localhost:8529 / _api / import?collection = test&createCollection = true ” [[“名字”,“姓”,“年龄”,“性别” ] [“乔”,“公众”,42,“男性”] [“简”,“母鹿”,31,“女性”]

Please help me in this regard. 请在这方面帮助我。

Thanks in advance 提前致谢

  • Mahi 马希

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) 您可以使用AQL轻松地从集合中删除一堆项目,例如:(就像您要在arangosh中执行它一样,这将使用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. 就像我对“ _key”属性所做的一样,您必须指定一个属性以匹配绑定值中的数组。

Using ngrep or wireshark you can easily find out howto send such an AQL query via the REST interface on your own without drivers: 使用ngrepwirehark,您可以轻松地找到如何通过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}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM