File size: 1,118 Bytes
1134589 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
import asyncio
from motor.motor_asyncio import AsyncIOMotorClient
client_tiktok = AsyncIOMotorClient("mongodb://localhost:27017/")
db_tiktok = client_tiktok["Akeno"]
collection = db_tiktok["session"]
async def get_session_all():
session = await collection.find().to_list(length=None)
print(session)
async def delete_session_all():
ok = await collection.delete_many({})
print("All sessions deleted.", ok.deleted_count)
async def approve_session_all():
session = await collection.find().to_list(length=None)
for i in session:
for client in i["user_client"]:
if client["status"] == "approved":
await collection.update_one(
{
"_id": i["_id"],
"user_client": {
"$elemMatch": {
"status": "approved"
}
}
},
{
"$set": {
"user_client.$.status": "approved",
"user_client.$.is_active": True,
}
}
)
asyncio.run(delete_session_all())
|