예제 #1
0
 async def add_model(self, model: Model):
     await self.db.models.insert_one(model.dict(exclude={"id"}))
예제 #2
0
 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"})})
예제 #3
0
 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
예제 #4
0
 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"])
예제 #5
0
 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"])