@@ -1172,7 +1172,6 @@ async def update_match(
1172
1172
keep_none : Optional [bool ] = None ,
1173
1173
wait_for_sync : Optional [bool ] = None ,
1174
1174
merge_objects : Optional [bool ] = None ,
1175
- allow_dirty_read : Optional [bool ] = None ,
1176
1175
) -> Result [int ]:
1177
1176
"""Update matching documents.
1178
1177
@@ -1185,10 +1184,9 @@ async def update_match(
1185
1184
wait_for_sync (bool | None): Wait until operation has been synced to disk.
1186
1185
merge_objects (bool | None): If set to `True`, sub-dictionaries are merged
1187
1186
instead of the new one overwriting the old one.
1188
- allow_dirty_read (bool | None): Allow reads from followers in a cluster.
1189
1187
1190
1188
Returns:
1191
- int: Number of documents updated.
1189
+ int: Number of documents that got updated.
1192
1190
1193
1191
Raises:
1194
1192
DocumentUpdateError: If update fails.
@@ -1213,18 +1211,11 @@ async def update_match(
1213
1211
"merge" : merge_objects ,
1214
1212
}
1215
1213
data = {"query" : query , "bindVars" : bind_vars }
1216
- headers : RequestHeaders = {}
1217
- if allow_dirty_read is not None :
1218
- if allow_dirty_read is True :
1219
- headers ["x-arango-allow-dirty-read" ] = "true"
1220
- else :
1221
- headers ["x-arango-allow-dirty-read" ] = "false"
1222
1214
1223
1215
request = Request (
1224
1216
method = Method .POST ,
1225
1217
endpoint = "/_api/cursor" ,
1226
1218
data = self .serializer .dumps (data ),
1227
- headers = headers ,
1228
1219
)
1229
1220
1230
1221
def response_handler (resp : Response ) -> int :
@@ -1241,7 +1232,6 @@ async def replace_match(
1241
1232
body : T ,
1242
1233
limit : Optional [int | str ] = None ,
1243
1234
wait_for_sync : Optional [bool ] = None ,
1244
- allow_dirty_read : Optional [bool ] = None ,
1245
1235
) -> Result [int ]:
1246
1236
"""Replace matching documents.
1247
1237
@@ -1250,7 +1240,6 @@ async def replace_match(
1250
1240
body (dict): New document body.
1251
1241
limit (int | str | None): Maximum number of documents to replace.
1252
1242
wait_for_sync (bool | None): Wait until operation has been synced to disk.
1253
- allow_dirty_read (bool | None): Allow reads from followers in a cluster.
1254
1243
1255
1244
Returns:
1256
1245
int: Number of documents that got replaced.
@@ -1276,18 +1265,11 @@ async def replace_match(
1276
1265
"body" : body ,
1277
1266
}
1278
1267
data = {"query" : query , "bindVars" : bind_vars }
1279
- headers : RequestHeaders = {}
1280
- if allow_dirty_read is not None :
1281
- if allow_dirty_read is True :
1282
- headers ["x-arango-allow-dirty-read" ] = "true"
1283
- else :
1284
- headers ["x-arango-allow-dirty-read" ] = "false"
1285
1268
1286
1269
request = Request (
1287
1270
method = Method .POST ,
1288
1271
endpoint = "/_api/cursor" ,
1289
1272
data = self .serializer .dumps (data ),
1290
- headers = headers ,
1291
1273
)
1292
1274
1293
1275
def response_handler (resp : Response ) -> int :
@@ -1298,6 +1280,55 @@ def response_handler(resp: Response) -> int:
1298
1280
1299
1281
return await self ._executor .execute (request , response_handler )
1300
1282
1283
+ async def delete_match (
1284
+ self ,
1285
+ filters : Json ,
1286
+ limit : Optional [int | str ] = None ,
1287
+ wait_for_sync : Optional [bool ] = None ,
1288
+ ) -> Result [int ]:
1289
+ """Delete matching documents.
1290
+
1291
+ Args:
1292
+ filters (dict | None): Query filters.
1293
+ limit (int | str | None): Maximum number of documents to delete.
1294
+ wait_for_sync (bool | None): Wait until operation has been synced to disk.
1295
+
1296
+ Returns:
1297
+ int: Number of documents that got deleted.
1298
+
1299
+ Raises:
1300
+ DocumentDeleteError: If delete fails.
1301
+ """
1302
+ if not self ._is_none_or_dict (filters ):
1303
+ raise ValueError ("filters parameter must be a dict" )
1304
+ if not (self ._is_none_or_int (limit ) or limit == "null" ):
1305
+ raise ValueError ("limit parameter must be a non-negative int" )
1306
+
1307
+ sync = f"waitForSync: { wait_for_sync } " if wait_for_sync is not None else ""
1308
+ query = f"""
1309
+ FOR doc IN @@collection
1310
+ { self ._build_filter_conditions (filters )}
1311
+ { f"LIMIT { limit } " if limit is not None else "" }
1312
+ REMOVE doc IN @@collection
1313
+ { f"OPTIONS {{ { sync } }}" if sync else "" }
1314
+ """ # noqa: E201 E202
1315
+ bind_vars = {"@collection" : self .name }
1316
+ data = {"query" : query , "bindVars" : bind_vars }
1317
+
1318
+ request = Request (
1319
+ method = Method .POST ,
1320
+ endpoint = "/_api/cursor" ,
1321
+ data = self .serializer .dumps (data ),
1322
+ )
1323
+
1324
+ def response_handler (resp : Response ) -> int :
1325
+ if resp .is_success :
1326
+ result = self .deserializer .loads (resp .raw_body )
1327
+ return cast (int , result ["extra" ]["stats" ]["writesExecuted" ])
1328
+ raise DocumentDeleteError (resp , request )
1329
+
1330
+ return await self ._executor .execute (request , response_handler )
1331
+
1301
1332
async def insert_many (
1302
1333
self ,
1303
1334
documents : Sequence [T ],
0 commit comments