提到这个问题,现在我想从中删除dinner
,Random Name 2
我该怎么做:这是我尝试过的:
din_val = data[0]
condition = {
"username" : session['user']["username"],
f"likings.{din_val}" : {
"$exists" : True
}
}
update_value = {
"$pull" : {
f"likings.$" : din_val
}
}
response = mongo.db.appname.update(condition, update_value)
但我收到的错误是
pymongo.errors.WriteError: Cannot apply $pull to a non-array value, full error: {'index': 0, 'code': 2, 'errmsg': 'Cannot apply $pull to a non-array value'}