Created
October 3, 2014 08:53
-
-
Save Quentin01/b2c156bbe00b2f2e62eb to your computer and use it in GitHub Desktop.
Add deduplicator to company
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'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