Initializing multitenant
This commit is contained in:
@@ -3,20 +3,22 @@ import motor.motor_asyncio
|
||||
from beanie import init_beanie
|
||||
|
||||
from .user import User, AccessToken
|
||||
from .entity.models import Entity
|
||||
from .template.models import ContractTemplate, ProvisionTemplate
|
||||
from .contract.models import ContractDraft, Contract
|
||||
|
||||
DB_PASSWORD = "IBO3eber0mdw2R9pnInLdtFykQFY2f06"
|
||||
DATABASE_URL = f"mongodb://root:{DB_PASSWORD}@mongo:27017/"
|
||||
|
||||
client = motor.motor_asyncio.AsyncIOMotorClient(
|
||||
DATABASE_URL, uuidRepresentation="standard"
|
||||
)
|
||||
|
||||
async def init_db():
|
||||
client = motor.motor_asyncio.AsyncIOMotorClient(
|
||||
DATABASE_URL, uuidRepresentation="standard"
|
||||
)
|
||||
|
||||
await init_beanie(database=client.db_name,
|
||||
document_models=[User, AccessToken, Entity, ContractTemplate, ProvisionTemplate, ContractDraft,
|
||||
Contract, ],
|
||||
await init_beanie(database=client.core,
|
||||
document_models=[User, AccessToken, ], # Entity, ContractTemplate, ProvisionTemplate, ContractDraft, Contract,
|
||||
allow_index_dropping=True)
|
||||
|
||||
|
||||
async def stop_db():
|
||||
client.close()
|
||||
|
||||
def get_db_client():
|
||||
yield client
|
||||
Reference in New Issue
Block a user