
    vdx                     B    d Z ddlZddlZddlmZ  G d de          ZdS )zImplementation of the DbDoc.    N   )STRING_TYPESc                   0    e Zd ZdZd Zd Zd Zd Zd ZdS )DbDoczRepresents a generic document in JSON format.

    Args:
        value (object): The value can be a JSON string or a dict.

    Raises:
        ValueError: If ``value`` type is not a basestring or dict.
    c                     t          |t                    r	|| _        d S t          |t                    rt	          j        |          | _        d S t          d                    t          |                              )NzUnable to handle type: {0})	
isinstancedict__dict__r   jsonloads
ValueErrorformattype)selfvalues     H/var/www/html/t/fyr/venv311/lib/python3.11/site-packages/mysqlx/dbdoc.py__init__zDbDoc.__init__)   sk    eT"" 	O!DMMM|,, 	O Ju--DMMM9@@eMMNNN    c                     | j         |         S N)r
   )r   indexs     r   __getitem__zDbDoc.__getitem__2   s    }U##r   c                 4    | j                                         S r   )r
   keysr   s    r   r   z
DbDoc.keys5   s    }!!###r   c                 n    d| j         vr t          j                    j        | j         d<   | j         d         S )N_id)r
   uuiduuid4hexr   s    r   	ensure_idzDbDoc.ensure_id8   s1    %%#':<<#3DM% }U##r   c                 4    t          j        | j                  S r   )r   dumpsr
   r   s    r   __str__zDbDoc.__str__=   s    z$-(((r   N)	__name__
__module____qualname____doc__r   r   r   r!   r$    r   r   r   r       sl         O O O$ $ $$ $ $$ $ $
) ) ) ) )r   r   )r(   r   r   compatr   objectr   r)   r   r   <module>r,      se   0 # "              ) ) ) ) )F ) ) ) ) )r   