Skip to content

Commit 906a770

Browse files
committed
RR feedback
1 parent 4131fe3 commit 906a770

File tree

1 file changed

+19
-8
lines changed

1 file changed

+19
-8
lines changed

source/data-formats/bson.txt

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -124,23 +124,34 @@ Work with Raw BSON Data
124124
some situations that might require using raw BSON documents:
125125

126126
- Moving a document between databases or collections
127-
- Writing binary blobs to a disk
127+
- Writing binary data to a disk
128128
- Bypassing the performance overhead of converting to and from {+language+} dictionaries
129129

130-
You can use the ``RawBSONDocument`` class to represent raw BSON documents. To use
131-
``RawBSONDocument`` objects to represent documents in your collection, set the
132-
``document_class`` parameter of the ``MongoClient`` constructor to ``RawBSONDocument``.
130+
The ``RawBSONDocument`` class is a representation of a BSON document that provides
131+
access to the underlying raw BSON bytes. To use ``RawBSONDocument`` objects to represent
132+
documents in your collection, set the ``document_class`` parameter of the ``MongoClient``
133+
constructor to ``RawBSONDocument``.
133134

134-
The following example configures a ``MongoClient`` object to use ``RawBSONDocument``,
135-
then retrieves the sample document:
135+
The following example configures a ``MongoClient`` object to use ``RawBSONDocument`` objects
136+
to model the collection, then retrieves the sample document from the preceding examples:
136137

137-
.. code-block:: python
138+
.. io-code-block::
139+
:copyable: true
140+
141+
.. input::
142+
:language: python
138143

139144
from bson.raw_bson import RawBSONDocument
140145

141146
client = pymongo.MongoClient("<connection URI>", document_class=RawBSONDocument)
142-
collection = client["<database name>"]["<collection name>"]
147+
collection = client.sample_restaurants.restaurants
143148
raw_doc = collection.find_one({"name": "Mongo's Pizza"})
149+
print(type(raw_doc))
150+
151+
.. output::
152+
:visible: false
153+
154+
<class 'bson.raw_bson.RawBSONDocument'>
144155

145156
.. note::
146157

0 commit comments

Comments
 (0)