1 year ago
#380142
Kota
pymongo.errors.OperationFailure: $and/$or/$nor
I tried coding like this:
input_filter = {"$and": []}
if not includeTestAccount:
b = {"userLoginKey": {"$not": {"$regex": "^777"}}}
input_filter["$and"].append(b)
if search_user_login_key is not None and search_user_login_key != "":
b = {"userLoginKey":{"$regex":search_user_login_key}}
input_filter["$and"].append(b)
if except_for_deletedaccount:
b = {"deletedAt": {"$not": {"$regex": None}}}
input_filter["$and"].append(b)
if except_for_deletedaccount:
b = {"deletedAt": {"$not": {"$regex": None}}}
input_filter["$and"].append(b)
but there was error in pymongo?:
pymongo.errors.OperationFailure: $and/$or/$nor must be a nonempty array,
full error: {'ok': 0.0, 'errmsg': '$and/$or/$nor must be a nonempty array', 'code': 2, 'codeName': 'BadValue'}
python-3.x
mongodb
pymongo
0 Answers
Your Answer