mongodb 根据条件查询,然后批量更新并输出日志。
db.user
.find({"affixPath":{$regex:"http"}, "affixDateTime":{$gt:"2021-08-01 10:00:00"}})
.forEach(
function(item) {
var path = String(item.affixPath)
path = path.replace('https://xxx.co.id//upload//','')
if (path == null){
print(item.affixPath)
}else {
print(item.affixPath);
print(path);
item.affixPath = path ;
db.user.save(item);
}
})