您可以使用 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}