+\hddZddlmZddlmZddlmZmZmZddl m Z m Z ddl m Z GddZy ) z@Tools for manipulating DBRefs (references to MongoDB documents).) annotations)deepcopy)AnyMappingOptional)_getstate_slots_setstate_slots)SONceZdZdZdZeZeZdZ d ddZ e ddZ e ddZ e ddZdd Zdd Zdd Zdd Zdd ZddZddZy)DBRefz,A reference to a document stored in MongoDB.) __collection__id __database__kwargsdNc t|tstdt||'t|tstdt|||_||_||_|j|xsi||_y)aInitialize a new :class:`DBRef`. Raises :class:`TypeError` if `collection` or `database` is not an instance of :class:`str`. `database` is optional and allows references to documents to work across databases. Any additional keyword arguments will create additional fields in the resultant embedded document. :param collection: name of the collection the document is stored in :param id: the value of the document's ``"_id"`` field :param database: name of the database to reference :param kwargs: additional keyword arguments will create additional, custom fields .. seealso:: The MongoDB documentation on `dbrefs `_. z+collection must be an instance of str, not Nz)database must be an instance of str, not ) isinstancestr TypeErrortype_DBRef__collection _DBRef__id_DBRef__databaseupdate_DBRef__kwargs)self collectioniddatabase_extrakwargss M/root/niggaflix-v3/playground/venv/lib/python3.12/site-packages/bson/dbref.py__init__zDBRef.__init__"s{0*c*I$zJZI[\] ]   8S(AGXGWXY Y& " fl# c|jS)z(Get the name of this DBRef's collection.)rrs r"rzDBRef.collectionEs   r$c|jS)zGet this DBRef's _id.)rr&s r"rzDBRef.idJsyyr$c|jS)zoGet the name of this DBRef's database. Returns None if this DBRef doesn't specify a database. )rr&s r"rzDBRef.databaseOs r$cT |j|S#t$r t|dwxYwN)rKeyErrorAttributeError)rkeys r" __getattr__zDBRef.__getattr__Ws2 0==% % 0 %4 / 0s'ctd|jfd|jfg}|j|j|d<|j |j |S)zsGet the SON document representation of this DBRef. Generally not needed by application developers z$refz$idz$db)r rrrrr)rdocs r"as_docz DBRef.as_doc]sQ FDOO,udgg.>?@ == $CJ 4==! r$c @dj|jjDcgc] \}}d|d|c}}}|jd|jd|j |dSd|jd|j d|j|dScc}}w)Nz, =zDBRef())joinritemsrrr)rkvextras r"__repr__zDBRef.__repr__hsDMM4G4G4IJDAq2aS!JK == DOO.b E7!D D*"TWWKr$--9J5'QRSSKsB ct|tra|j|j|j|j f}|j|j|j|j f}||k(St Sr*)rr rrrrNotImplemented)rotherusthems r"__eq__z DBRef.__eq__ns^ eU #//4#4#4diiOB$$e&8&8%**ennUD: r$c||k( Sr*)rr>s r"__ne__z DBRef.__ne__us5=  r$c t|j|j|jt t |j jfS)z)Get a hash value for this :class:`DBRef`.)hashrrrtuplesortedrr7r&s r"__hash__zDBRef.__hash__xs@    4??E&I\I\I^B_<` a  r$c tt|j|t|j|t|j|t|j |S)z'Support function for `copy.deepcopy()`.)r rrrrr)rmemos r" __deepcopy__zDBRef.__deepcopy__~sI T&& - TYY % T__d + T]]D )   r$)NN) rrrrr Optional[str]r zOptional[Mapping[str, Any]]r!rreturnNone)rNr)rNr)rNrM)r-rrNr)rNz SON[str, Any])r>rrNbool)rNint)rKrrNr )__name__ __module__ __qualname____doc__ __slots__r __getstate__r __setstate__ _type_markerr#propertyrrrr.r1r;rArDrIrLrCr$r"r r s6@I"L"LL #'.2 !! ! ! , !  ! !F!!0 T !  r$r N)rU __future__rcopyrtypingrrr bson._helpersrr bson.sonr r rCr$r"r`s)G")):l l r$