Skip to content

Instantly share code, notes, and snippets.

@Quentin01
Created October 3, 2014 08:53
Show Gist options
  • Save Quentin01/b2c156bbe00b2f2e62eb to your computer and use it in GitHub Desktop.
Save Quentin01/b2c156bbe00b2f2e62eb to your computer and use it in GitHub Desktop.
Add deduplicator to company
'use strict';
require('./app.js');
var async = require('async');
var mongoose = require('mongoose');
var Company = mongoose.model('Company');
Company.find().exec(function(err, companies) {
if (err) {
console.log(err);
process.exit(1);
}
async.each(companies, function(company, cb) {
if(company.hydraters.indexOf("https://deduplicator.anyfetch.com/hydrate") !== -1) {
return cb(null);
}
company.hydraters.push("https://deduplicator.anyfetch.com/hydrate");
company.save(cb);
}, function(err) {
if (err) {
console.log(err);
process.exit(1);
}
mongoose.disconnect();
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment