Example #1
0
 def save(cls, model):
     """
     Сохраняет модель в базу.
     @param model: Model
     """
     data = cls.model_to_dict(model)
     model._id = DbClient.get_collection(cls._collection).save(data, manipulate=True)
Example #2
0
 def find(cls, filter):
     """
     Ищет записи.
     @param filter: dict
     @return: list
     """
     data = DbClient.get_collection(cls._collection).find(filter)
     return map(cls.dict_to_model, data)
Example #3
0
 def find_one(cls, filter):
     """
     Ищет одну запись.
     @param filter: dict
     @return: Model
     """
     data = DbClient.get_collection(cls._collection).find_one(filter)
     if data is None:
         return None
     return cls.dict_to_model(data)