SequoiaDB
 All Classes Functions
Public Member Functions | List of all members
bson.binary.UUIDLegacy Class Reference
Inheritance diagram for bson.binary.UUIDLegacy:
bson.binary.Binary

Public Member Functions

def __new__
 
def __getnewargs__
 
def uuid
 
def __repr__
 
- Public Member Functions inherited from bson.binary.Binary
def __new__
 
def subtype
 
def __getnewargs__
 
def __eq__
 
def __ne__
 
def __repr__
 

Detailed Description

UUID wrapper to support working with UUIDs stored as legacy
BSON binary subtype 3.

.. doctest::

  >>> import uuid
  >>> from bson.binary import Binary, UUIDLegacy, UUID_SUBTYPE
  >>> my_uuid = uuid.uuid4()
  >>> coll = db.test
  >>> coll.uuid_subtype = UUID_SUBTYPE
  >>> coll.insert({'uuid': Binary(my_uuid.bytes, 3)})
  ObjectId('...')
  >>> coll.find({'uuid': my_uuid}).count()
  0
  >>> coll.find({'uuid': UUIDLegacy(my_uuid)}).count()
  1
  >>> coll.find({'uuid': UUIDLegacy(my_uuid)})[0]['uuid']
  UUID('...')
  >>>
  >>> # Convert from subtype 3 to subtype 4
  >>> doc = coll.find_one({'uuid': UUIDLegacy(my_uuid)})
  >>> coll.save(doc)
  ObjectId('...')
  >>> coll.find({'uuid': UUIDLegacy(my_uuid)}).count()
  0
  >>> coll.find({'uuid': {'$in': [UUIDLegacy(my_uuid), my_uuid]}}).count()
  1
  >>> coll.find_one({'uuid': my_uuid})['uuid']
  UUID('...')

Raises TypeError if `obj` is not an instance of :class:`~uuid.UUID`.

:Parameters:
  - `obj`: An instance of :class:`~uuid.UUID`.

Member Function Documentation

def bson.binary.UUIDLegacy.uuid (   self)
UUID instance wrapped by this UUIDLegacy instance.

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