|
OpenQuizz
Une application de gestion des contenus pédagogiques
|


Public Member Functions | |
| def | __init__ (self, bson_bytes, codec_options=None) |
| def | raw (self) |
| def | items (self) |
| def | __getitem__ (self, item) |
| def | __iter__ (self) |
| def | __len__ (self) |
| def | __eq__ (self, other) |
| def | __repr__ (self) |
Representation for a MongoDB document that provides access to the raw BSON bytes that compose it. Only when a field is accessed or modified within the document does RawBSONDocument decode its bytes.
| def __init__ | ( | self, | |
| bson_bytes, | |||
codec_options = None |
|||
| ) |
Create a new :class:`RawBSONDocument`
:class:`RawBSONDocument` is a representation of a BSON document that
provides access to the underlying raw BSON bytes. Only when a field is
accessed or modified within the document does RawBSONDocument decode
its bytes.
:class:`RawBSONDocument` implements the ``Mapping`` abstract base
class from the standard library so it can be used like a read-only
``dict``::
>>> from bson import encode
>>> raw_doc = RawBSONDocument(encode({'_id': 'my_doc'}))
>>> raw_doc.raw
b'...'
>>> raw_doc['_id']
'my_doc'
:Parameters:
- `bson_bytes`: the BSON bytes that compose this document
- `codec_options` (optional): An instance of
:class:`~bson.codec_options.CodecOptions` whose ``document_class``
must be :class:`RawBSONDocument`. The default is
:attr:`DEFAULT_RAW_BSON_OPTIONS`.
.. versionchanged:: 3.8
:class:`RawBSONDocument` now validates that the ``bson_bytes``
passed in represent a single bson document.
.. versionchanged:: 3.5
If a :class:`~bson.codec_options.CodecOptions` is passed in, its
`document_class` must be :class:`RawBSONDocument`.
| def __eq__ | ( | self, | |
| other | |||
| ) |
| def __getitem__ | ( | self, | |
| item | |||
| ) |
| def __iter__ | ( | self | ) |
| def __len__ | ( | self | ) |
| def __repr__ | ( | self | ) |
| def items | ( | self | ) |
Lazily decode and iterate elements in this document.
| def raw | ( | self | ) |
The raw BSON bytes composing this document.