mongo $and list should not contain list elements in order to avoid this error:

$and/$or elements must be objects
This commit is contained in:
aeroeng 2015-01-06 14:37:40 -05:00 committed by stefan rusu
parent 0ffe79d76c
commit d80be60e2b

View File

@ -160,7 +160,7 @@ def query(_doc_cls=None, _field_operation=False, **query):
if isinstance(v, list): if isinstance(v, list):
value = [{k: val} for val in v] value = [{k: val} for val in v]
if '$and' in mongo_query.keys(): if '$and' in mongo_query.keys():
mongo_query['$and'].append(value) mongo_query['$and'].extend(value)
else: else:
mongo_query['$and'] = value mongo_query['$and'] = value