admin_dashboard_backend / update_chatbot_id.py
vip11017's picture
Added upate_chatbot_id.py file
1c96f76
raw
history blame contribute delete
593 Bytes
import asyncio
from motor.motor_asyncio import AsyncIOMotorClient
from app.config import settings
async def rename_field():
client = AsyncIOMotorClient(settings.mongo_uri)
db = client[settings.mongo_db_name]
chat_logs = db["ChatLogs"]
result = await chat_logs.update_many(
{"chatbot": {"$exists": True}}, # filter documents where "chatbot" exists
{"$rename": {"chatbot": "chatbot_id"}} # rename field
)
print(f"Matched {result.matched_count}, Modified {result.modified_count} documents.")
if __name__ == "__main__":
asyncio.run(rename_field())