PYTHON-2748 Fix error in UUID example (#650)
(cherry picked from commit 00f7fe8ce3)
This commit is contained in:
parent
1b2a599706
commit
b03e5989c0
@ -255,19 +255,27 @@ Applications can set the UUID representation in one of the following ways:
|
||||
* - ``unspecified``
|
||||
- :ref:`unspecified-representation-details`
|
||||
|
||||
#. Using the ``uuid_representation`` kwarg option, e.g.::
|
||||
#. At the ``MongoClient`` level using the ``uuidRepresentation`` kwarg
|
||||
option, e.g.::
|
||||
|
||||
from bson.binary import UuidRepresentation
|
||||
client = MongoClient(uuid_representation=UuidRepresentation.PYTHON_LEGACY)
|
||||
client = MongoClient(uuidRepresentation=UuidRepresentation.PYTHON_LEGACY)
|
||||
|
||||
#. By supplying a suitable :class:`~bson.codec_options.CodecOptions`
|
||||
instance, e.g.::
|
||||
#. At the ``Database`` or ``Collection`` level by supplying a suitable
|
||||
:class:`~bson.codec_options.CodecOptions` instance, e.g.::
|
||||
|
||||
from bson.codec_options import CodecOptions
|
||||
csharp_opts = CodecOptions(uuid_representation=UuidRepresentation.CSHARP_LEGACY)
|
||||
java_opts = CodecOptions(uuid_representation=UuidRepresentation.JAVA_LEGACY)
|
||||
|
||||
# Get database/collection from client with csharpLegacy UUID representation
|
||||
csharp_database = client.get_database('csharp_db', codec_options=csharp_opts)
|
||||
csharp_collection = client.testdb.get_collection('csharp_coll', codec_options=csharp_opts)
|
||||
|
||||
# Get database/collection from existing database/collection with javaLegacy UUID representation
|
||||
java_database = csharp_database.with_options(codec_options=java_opts)
|
||||
java_collection = csharp_collection.with_options(codec_options=java_opts)
|
||||
|
||||
Supported UUID Representations
|
||||
------------------------------
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user