Exemple #1
0
 def make_ref(dbref):
     return DBRef(make_elem(dbref[0]), make_elem(dbref[1]))
Exemple #2
0
def _get_object(data):
    (object, data) = _bson_to_dict(data)
    if "$ref" in object:
        return (DBRef(object["$ref"], object["$id"], object.get("$db",
                                                                None)), data)
    return (object, data)
Exemple #3
0
def _get_ref(data):
    (collection, data) = _get_c_string(data[4:])
    (oid, data) = _get_oid(data)
    return (DBRef(collection, oid), data)
Exemple #4
0
def object_hook(dct):
    if "$oid" in dct:
        return ObjectId(str(dct["$oid"]))
    if "$ref" in dct:
        return DBRef(dct["$ref"], dct["$id"], dct.get("$db", None))
    return dct