Internal delete helper.
(
self,
conn: AsyncConnection,
criteria: Mapping[str, Any],
multi: bool,
write_concern: Optional[WriteConcern] = None,
op_id: Optional[int] = None,
ordered: bool = True,
collation: Optional[_CollationIn] = None,
hint: Optional[_IndexKeyHint] = None,
session: Optional[AsyncClientSession] = None,
retryable_write: bool = False,
let: Optional[Mapping[str, Any]] = None,
comment: Optional[Any] = None,
)
| 1496 | ) |
| 1497 | |
| 1498 | async def _delete( |
| 1499 | self, |
| 1500 | conn: AsyncConnection, |
| 1501 | criteria: Mapping[str, Any], |
| 1502 | multi: bool, |
| 1503 | write_concern: Optional[WriteConcern] = None, |
| 1504 | op_id: Optional[int] = None, |
| 1505 | ordered: bool = True, |
| 1506 | collation: Optional[_CollationIn] = None, |
| 1507 | hint: Optional[_IndexKeyHint] = None, |
| 1508 | session: Optional[AsyncClientSession] = None, |
| 1509 | retryable_write: bool = False, |
| 1510 | let: Optional[Mapping[str, Any]] = None, |
| 1511 | comment: Optional[Any] = None, |
| 1512 | ) -> Mapping[str, Any]: |
| 1513 | """Internal delete helper.""" |
| 1514 | common.validate_is_mapping("filter", criteria) |
| 1515 | write_concern = write_concern or self.write_concern |
| 1516 | acknowledged = write_concern.acknowledged |
| 1517 | delete_doc = {"q": criteria, "limit": int(not multi)} |
| 1518 | collation = validate_collation_or_none(collation) |
| 1519 | if collation is not None: |
| 1520 | if not acknowledged: |
| 1521 | raise ConfigurationError("Collation is unsupported for unacknowledged writes.") |
| 1522 | else: |
| 1523 | delete_doc["collation"] = collation |
| 1524 | if hint is not None: |
| 1525 | if not acknowledged and conn.max_wire_version < 9: |
| 1526 | raise ConfigurationError( |
| 1527 | "Must be connected to MongoDB 4.4+ to use hint on unacknowledged delete commands." |
| 1528 | ) |
| 1529 | if not isinstance(hint, str): |
| 1530 | hint = helpers_shared._index_document(hint) |
| 1531 | delete_doc["hint"] = hint |
| 1532 | command = {"delete": self.name, "ordered": ordered, "deletes": [delete_doc]} |
| 1533 | |
| 1534 | if let is not None: |
| 1535 | common.validate_is_document_type("let", let) |
| 1536 | command["let"] = let |
| 1537 | |
| 1538 | if comment is not None: |
| 1539 | command["comment"] = comment |
| 1540 | |
| 1541 | # Delete command. |
| 1542 | result = await conn.command( |
| 1543 | self._database.name, |
| 1544 | command, |
| 1545 | write_concern=write_concern, |
| 1546 | codec_options=self._write_response_codec_options, |
| 1547 | session=session, |
| 1548 | client=self._database.client, |
| 1549 | retryable_write=retryable_write, |
| 1550 | ) |
| 1551 | _check_write_command_response(result) |
| 1552 | return result |
| 1553 | |
| 1554 | async def _delete_retryable( |
| 1555 | self, |
nothing calls this directly
no test coverage detected