@@ -1447,3 +1447,77 @@ def response_handler(
1447
1447
return self .deserializer .loads_many (resp .raw_body )
1448
1448
1449
1449
return await self ._executor .execute (request , response_handler )
1450
+
1451
+ async def delete_many (
1452
+ self ,
1453
+ documents : Sequence [T ],
1454
+ wait_for_sync : Optional [bool ] = None ,
1455
+ ignore_revs : Optional [bool ] = None ,
1456
+ return_old : Optional [bool ] = None ,
1457
+ silent : Optional [bool ] = None ,
1458
+ refill_index_caches : Optional [bool ] = None ,
1459
+ ) -> Result [Jsons ]:
1460
+ """Delete multiple documents.
1461
+
1462
+ Note:
1463
+ If deleting a document fails, the exception is not raised but
1464
+ returned as an object in the "errors" list. It is up to you to
1465
+ inspect the list to determine which documents were deleted
1466
+ successfully (returned as document metadata) and which were not
1467
+ (returned as exception object).
1468
+
1469
+ Args:
1470
+ documents (list): Documents to delete. An item must contain the "_key" or
1471
+ "_id" field.
1472
+ wait_for_sync (bool | None): Wait until documents have been synced to disk.
1473
+ ignore_revs (bool | None): If this is set to `False`, then any `_rev`
1474
+ attribute given in a body document is taken as a precondition. The
1475
+ document is only updated if the current revision is the one
1476
+ specified.
1477
+ return_old (bool | None): Additionally return the complete old document
1478
+ under the attribute `old` in the result.
1479
+ silent (bool | None): If set to `True`, an empty object is returned as
1480
+ response if all document operations succeed. No meta-data is returned
1481
+ for the created documents. If any of the operations raises an error,
1482
+ an array with the error object(s) is returned.
1483
+ refill_index_caches (bool | None): Whether to add new entries to
1484
+ in-memory index caches if document operations affect the edge index
1485
+ or cache-enabled persistent indexes.
1486
+
1487
+ Returns:
1488
+ list: Documents metadata (e.g. document id, key, revision) and
1489
+ errors or just errors if **silent** is set to `True`.
1490
+
1491
+ Raises:
1492
+ DocumentRemoveError: If removal fails.
1493
+
1494
+ References:
1495
+ - `remove-multiple-documents <https://docs.arangodb.com/stable/develop/http-api/documents/#remove-multiple-documents>`__
1496
+ """ # noqa: E501
1497
+ params : Params = {}
1498
+ if wait_for_sync is not None :
1499
+ params ["waitForSync" ] = wait_for_sync
1500
+ if ignore_revs is not None :
1501
+ params ["ignoreRevs" ] = ignore_revs
1502
+ if return_old is not None :
1503
+ params ["returnOld" ] = return_old
1504
+ if silent is not None :
1505
+ params ["silent" ] = silent
1506
+ if refill_index_caches is not None :
1507
+ params ["refillIndexCaches" ] = refill_index_caches
1508
+
1509
+ request = Request (
1510
+ method = Method .DELETE ,
1511
+ endpoint = f"/_api/document/{ self .name } " ,
1512
+ data = self ._doc_serializer .dumps (documents ),
1513
+ params = params ,
1514
+ )
1515
+
1516
+ def response_handler (
1517
+ resp : Response ,
1518
+ ) -> Jsons :
1519
+ if not resp .is_success :
1520
+ raise DocumentDeleteError (resp , request )
1521
+ return self .deserializer .loads_many (resp .raw_body )
1522
+
1523
+ return await self ._executor .execute (request , response_handler )
0 commit comments