Execute operations.
(
self,
session: Optional[AsyncClientSession],
operation: str,
)
| 736 | return await self.execute_command_unack(conn) |
| 737 | |
| 738 | async def execute( |
| 739 | self, |
| 740 | session: Optional[AsyncClientSession], |
| 741 | operation: str, |
| 742 | ) -> Any: |
| 743 | """Execute operations.""" |
| 744 | if not self.ops: |
| 745 | raise InvalidOperation("No operations to execute") |
| 746 | if self.executed: |
| 747 | raise InvalidOperation("Bulk operations can only be executed once.") |
| 748 | self.executed = True |
| 749 | session = _validate_session_write_concern(session, self.write_concern) |
| 750 | |
| 751 | if not self.write_concern.acknowledged: |
| 752 | async with await self.client._conn_for_writes(session, operation) as connection: |
| 753 | if connection.max_wire_version < 25: |
| 754 | raise InvalidOperation( |
| 755 | "MongoClient.bulk_write requires MongoDB server version 8.0+." |
| 756 | ) |
| 757 | await self.execute_no_results(connection) |
| 758 | return ClientBulkWriteResult(None, False, False) # type: ignore[arg-type] |
| 759 | |
| 760 | result = await self.execute_command(session, operation) |
| 761 | return ClientBulkWriteResult( |
| 762 | result, |
| 763 | self.write_concern.acknowledged, |
| 764 | self.verbose_results, |
| 765 | ) |
nothing calls this directly
no test coverage detected