def update(self, public_id: Union[PublicID, int], category: Union[CategoryModel, dict]): """ Update a existing category in the system. Args: public_id (int): PublicID of the category in the system. category: New category data Notes: If a CategoryModel instance was passed as type argument, \ it will be auto converted via the model `to_json` method. """ if isinstance(category, CategoryModel): category = CategoryModel.to_json(category) update_result = self._update(self.collection, filter={'public_id': public_id}, resource=category) if update_result.matched_count != 1: raise ManagerUpdateError(f'Something happened during the update!') return update_result
def update(self, public_id: Union[PublicID, int], type: Union[TypeModel, dict]): """ Update a existing type in the system. Args: public_id (int): PublicID of the type in the system. type: New type data Notes: If a TypeModel instance was passed as type argument, \ it will be auto converted via the model `to_json` method. """ if isinstance(type, TypeModel): type = TypeModel.to_json(type) update_result = self._update(self.collection, filter={'public_id': public_id}, resource=type) if update_result.matched_count != 1: raise ManagerUpdateError(f'Something happened during the update!') return update_result