Skip to content

Instantly share code, notes, and snippets.

@mrvictorn
Last active June 7, 2017 14:42
Show Gist options
  • Save mrvictorn/f545112850351d38d9d9201370d3ccd8 to your computer and use it in GitHub Desktop.
Save mrvictorn/f545112850351d38d9d9201370d3ccd8 to your computer and use it in GitHub Desktop.
var Campaign = require('../models/Campaign');
const re = new RegExp('( )?(\||\:|\-)?( |[(])?EXCLUSIEF(.*)');
const d = Campaign.default.find({'offer.text':{$regex: re}}).cursor();
d.on('data', o=>{
console.log(o._id,o.offer.text);
Campaign.default.update({_id:o._id}, {$set:{'offer.text': o.title.replace(re,'').replace('|','').trim()}}).then(ee=>console.log(ee));
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment