Unpack a response from the database and decode the BSON document(s). Check the response for errors and unpack, returning a dictionary containing the response data. Can raise CursorNotFound, NotPrimaryError, ExecutionTimeout, or OperationFailure. :param curs
(
self,
cursor_id: Optional[int] = None,
codec_options: CodecOptions[Any] = _UNICODE_REPLACE_CODEC_OPTIONS,
user_fields: Optional[Mapping[str, Any]] = None,
legacy_response: bool = False,
)
| 1403 | return [] |
| 1404 | |
| 1405 | def unpack_response( |
| 1406 | self, |
| 1407 | cursor_id: Optional[int] = None, |
| 1408 | codec_options: CodecOptions[Any] = _UNICODE_REPLACE_CODEC_OPTIONS, |
| 1409 | user_fields: Optional[Mapping[str, Any]] = None, |
| 1410 | legacy_response: bool = False, |
| 1411 | ) -> list[dict[str, Any]]: |
| 1412 | """Unpack a response from the database and decode the BSON document(s). |
| 1413 | |
| 1414 | Check the response for errors and unpack, returning a dictionary |
| 1415 | containing the response data. |
| 1416 | |
| 1417 | Can raise CursorNotFound, NotPrimaryError, ExecutionTimeout, or |
| 1418 | OperationFailure. |
| 1419 | |
| 1420 | :param cursor_id: cursor_id we sent to get this response - |
| 1421 | used for raising an informative exception when we get cursor id not |
| 1422 | valid at server response |
| 1423 | :param codec_options: an instance of |
| 1424 | :class:`~bson.codec_options.CodecOptions` |
| 1425 | :param user_fields: Response fields that should be decoded |
| 1426 | using the TypeDecoders from codec_options, passed to |
| 1427 | bson._decode_all_selective. |
| 1428 | """ |
| 1429 | self.raw_response(cursor_id) |
| 1430 | if legacy_response: |
| 1431 | return bson.decode_all(self.documents, codec_options) |
| 1432 | return bson._decode_all_selective(self.documents, codec_options, user_fields) |
| 1433 | |
| 1434 | def command_response(self, codec_options: CodecOptions[Any]) -> dict[str, Any]: |
| 1435 | """Unpack a command response.""" |
no test coverage detected