Answer the question
In order to leave comments, you need to log in
How to make a request in mongoalchemy, with the condition of equality of 2 fields of the document?
Good day. I have a model for mongoalchemy:
class ImportProductReport(mongo.Document):
target = mongo.IntField(default=0)
processed = mongo.IntField(default=0)
is_in_process_remove_offers = mongo.BoolField(default=False)
is_old_offers_removed = mongo.BoolField(default=False)
...
res = ImportProductReport.query\
.filter(
ImportProductReport.is_old_offers_removed == False,
ImportProductReport.is_in_process_remove_offers == False
)\
.all()
res = ImportProductReport.query\
.filter(
ImportProductReport.is_old_offers_removed == False,
ImportProductReport.is_in_process_remove_offers == False,
ImportProductReport.target == ImportProductReport.processed
)\
.all()
AttributeError: 'bool' object has no attribute 'obj'
Answer the question
In order to leave comments, you need to log in
If suddenly someone will help, then I found the answer to my question.
Mongoalchemy allows queries to be made with a syntax similar to the original MongoDB syntax.
Therefore, the query I need can be written as follows:
res = ImportProductReport.query\
.filter({
'is_old_offers_removed': False,
'is_in_process_remove_offers': False,
'$where': 'this.target == this.processed'
})\
.all()
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question