0

我正在寻找在 ArangoDB 中执行批量删除的 API。我该怎么做?

我已经浏览了下面的链接......但我觉得它太乏味了。 https://docs.arangodb.com/HttpBatchRequest/index.html

实际上我正在寻找一些更简单的方法,例如批量导入语法(粘贴在下面供您参考)

curl --data-binary @- -X POST --dump - " http://localhost:8529/_api/import?collection=test&createCollection=true " [ "firstName", "lastName", "age", "gender" ] [“乔”、“公”、42、“男”] [“简”、“多伊”、31、“女”]

请在这方面帮助我。

提前致谢

  • 鲯鳅
4

1 回答 1

0

您可以使用 AQL 从集合中轻松删除一堆项目,如下所示:(就像您将在 arangosh 中执行它一样,它在术语中将使用 REST api)

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

正如我对“_key”属性所做的那样,您必须指定一个属性来匹配绑定值中的数组。

使用ngrepwireshark,您可以轻松了解如何通过 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}
于 2016-05-17T12:20:35.467 回答