问题描述
有人可以建议在update_many的过滤查询中使用正则表达式时如何更新多个文档吗?
这是我的查询:
db['collection'].update_many({"col1":{ "$regex" : "NO","$options" : "i"}},{"$set":{"col2":"NO"}})
解决方法
这是我使用的快速修复程序:
no_regex = ['no','No','NO']
db['collection'].update_many({"col1":{ "$in" : no_regex}},{"$set":{"col2":"NO"}})