0

I use mongoengine 0.15.0. I have a 'Report' model. In the model definition, there is a method statement:

def check(self):
        existing_object = self.__class__._get_collection().find({
        'draft_id': self.draft_question_id,
        'origin': self.fault_origin,
        'history.0.conclusion': Conclusion.UNPROCESSED,
    }, {'history.0': 1},).first()

I also want to set the read_preference option to ReadPreference.SECONDARY_PREFERRED. What should I do?

CandyCrusher
  • 308
  • 1
  • 14
  • *"I also want to set the read_preference option..."* - Why? If you are thinking in terms of "reading from my secondary must be faster" then you are thinking this for the wrong reason. Most applications really should stick with the default read preference unless you **fully** understand the implications. And there are **significant** implications. Don't just jump to this because you read it in someones blog post. Read the documentation and understand it first. – Neil Lunn Nov 21 '18 at 08:15
  • Ok expert, I will follow your instructions first – CandyCrusher Nov 21 '18 at 08:19

0 Answers0