async def add_model(self, model: Model): await self.db.models.insert_one(model.dict(exclude={"id"}))
async def update_model(self, model_url: str, post: Model): await self.db.models.update_one({"model_url": ObjectId(model_url)}, {"$set": post.dict(exclude={"id"})})
async def get_models(self) -> List[Model]: models_list = [] models_q = self.db.models.find() async for post in models_q: models_list.append(Model(**post, id=post["model_url"])) return models_list
async def get_model(self, model_url: str) -> Model: model_q = await self.db.models\ .find_one({"model_url": ObjectId(model_url)}) if model_q: return Model(**model_q, id=model_q["_id"])
async def get_model(self, model_url: str) -> Model: if (model_q := await self.db.models.find_one({"model_url": model_url})) is not None: return Model(**model_q, id=model_q["_id"])