OpenQuizz
Une application de gestion des contenus pédagogiques
RawBSONDocument Class Reference
Inheritance diagram for RawBSONDocument:
Collaboration diagram for RawBSONDocument:

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)
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ __init__()

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`.

Member Function Documentation

◆ __eq__()

def __eq__ (   self,
  other 
)

◆ __getitem__()

def __getitem__ (   self,
  item 
)

◆ __iter__()

def __iter__ (   self)

◆ __len__()

def __len__ (   self)

◆ __repr__()

def __repr__ (   self)

◆ items()

def items (   self)
Lazily decode and iterate elements in this document.

◆ raw()

def raw (   self)
The raw BSON bytes composing this document.

The documentation for this class was generated from the following file: