-
Notifications
You must be signed in to change notification settings - Fork 20
DOCSP-47282: RawBSONDocument information #176
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 4 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -117,6 +117,36 @@ The following example reads the sample BSON document from ``file.bson``: | |
|
||
{"address": {"street": "Pizza St", "zipcode": "10003"}, "coord": [-73.982419, 41.579505], "cuisine": "Pizza", "name": "Mongo's Pizza"} | ||
|
||
Work with Raw BSON Data | ||
----------------------- | ||
|
||
{+driver-short+} supports the usage of raw BSON documents. The following list contains | ||
some situations that might require using raw BSON documents: | ||
|
||
- Moving a document between databases or collections | ||
- Writing binary blobs to a disk | ||
- Bypassing the performance overhead of converting to and from {+language+} dictionaries | ||
|
||
You can use the ``RawBSONDocument`` class to represent raw BSON documents. To use | ||
mcmorisi marked this conversation as resolved.
Show resolved
Hide resolved
|
||
``RawBSONDocument`` objects to represent documents in your collection, set the | ||
``document_class`` parameter of the ``MongoClient`` constructor to ``RawBSONDocument``. | ||
|
||
The following example configures a ``MongoClient`` object to use ``RawBSONDocument``, | ||
then retrieves the sample document: | ||
mcmorisi marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
.. code-block:: python | ||
|
||
from bson.raw_bson import RawBSONDocument | ||
|
||
client = pymongo.MongoClient("<connection URI>", document_class=RawBSONDocument) | ||
collection = client["<database name>"]["<collection name>"] | ||
raw_doc = collection.find_one({"name": "Mongo's Pizza"}) | ||
mcmorisi marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
.. note:: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Placing a detail so important as a note after the example feels slightly confusing to me: I'd expect documentation to tell me immediately if a certain data representation was read-only or not. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I can move this up. |
||
|
||
``RawBSONDocument`` objects are read-only. To modify a ``RawBSONDocument``, you must | ||
first convert it to a {+language+} dictionary. | ||
|
||
API Documentation | ||
----------------- | ||
|
||
|
Uh oh!
There was an error while loading. Please reload this page.