33 lines
817 B
Python
33 lines
817 B
Python
import datetime
|
|
import os
|
|
from typing import Dict, List, Optional
|
|
|
|
from bson import ObjectId
|
|
from motor.motor_asyncio import (
|
|
AsyncIOMotorClient,
|
|
AsyncIOMotorCollection,
|
|
AsyncIOMotorDatabase,
|
|
)
|
|
|
|
MONGO_URI = os.getenv("MONGO_URI")
|
|
|
|
MongoQueryParam = int | str | None | bool | datetime.datetime
|
|
|
|
MongoQueryListParam = (
|
|
List[int] | List[str] | List[datetime.datetime] | List[bool] | List[None]
|
|
)
|
|
|
|
MongoQueryDictParam = Dict[
|
|
str, MongoQueryListParam | MongoQueryParam | "MongoQueryDictParam"
|
|
]
|
|
|
|
MongoQuery = Dict[
|
|
str, MongoQueryDictParam | MongoQueryParam | MongoQueryListParam | "MongoQuery"
|
|
]
|
|
|
|
# 明确的类型注解
|
|
client: AsyncIOMotorClient = AsyncIOMotorClient(host=MONGO_URI)
|
|
db: AsyncIOMotorDatabase = client["TriCore"]
|
|
voice_collection: AsyncIOMotorCollection = db["voice_insight"]
|
|
|