U
    ¶„Ÿhé  ã                   @   sf   d dl mZ d dlmZ d dlmZ d dlmZ G dd„ dƒZeƒ Z	dd„ Z
d	d
„ Zedœdd„ZdS )é    )ÚAsyncIOMotorClient)Úinit_beanie)Úconfig)ÚOptionalc                   @   s"   e Zd ZU dZee ed< dZdS )ÚMongoDBNÚclient)Ú__name__Ú
__module__Ú__qualname__r   r   r   Ú__annotations__Údatabase© r   r   úB/var/www/html/Mana-Pige/backend/account-service/shared/database.pyr      s   
r   c                  Ã   s@   t ddd} t ddd}t| ƒt_tj| t_td|› ƒ dS )zCreate database connectionZMONGODB_URLz(mongodb://admin:password@localhost:27017)ÚdefaultZDB_NAMEZmana_pige_dbzConnected to MongoDB: N)r   r   Úmongodbr   r   Úprint)Zmongodb_urlÚdb_namer   r   r   Úconnect_to_mongo   s
    
r   c                   Ã   s   t jrt j ¡  tdƒ dS )zClose database connectionzDisconnected from MongoDBN)r   r   Úcloser   r   r   r   r   Úclose_mongo_connection   s    
r   ©Údocument_modelsc                 Ã   s    t tj| dI dH  tdƒ dS )z&Initialize Beanie with document models)r   r   NzInitialized Beanie ODM)r   r   r   r   r   r   r   r   Úinit_database   s    r   N)Úmotor.motor_asyncior   Úbeanier   Zdecoupler   Útypingr   r   r   r   r   Úlistr   r   r   r   r   Ú<module>   s   
