我正在寻找一个 API 来在 ArangoDB 中执行批量删除。我怎样才能做到呢?
我已经浏览了下面的链接...但我觉得它太乏味了。 https://docs.arangodb.com/3.11/develop/http/batch-requests/
实际上我正在寻找一些更简单的方法,例如批量导入语法(粘贴在下面供您参考)
curl --data-binary @- -X POST --dump - “http://localhost:8529/_api/import?collection=test&createCollection=true” [“名字”,“姓氏”,“年龄”,“性别”] [“乔”,“公共”,42, “男”] [“简”、“多伊”、31、“女”]
请在这方面帮助我。
提前致谢
您可以使用 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}