Created
August 5, 2014 18:02
-
-
Save kyriesent/c7cb0f0df594217801d6 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
var acl = require('../routes/middleware/acl'); | |
var mongoose = require('mongoose'); | |
// var config = require('../libs/configurator'); don't need this | |
var config = require('../libs/configurator'); | |
var async = require('async'); | |
require('../models')(mongoose); | |
// mongoose.models.Works.find({}).exec(function (err, works) { <-- Work should be singular, as in below | |
mongoose.models.Work.find({}).exec(function (err, works) { | |
async.each(works, function (work, cb) { | |
mongoose.models.Group.find({"featured._work": work._id}, function (err, groups) { | |
if (err !== undefined) { | |
throw err | |
} else { | |
work.featuredIn = _.map(groups, function(group) { | |
_group: group._id.toString() | |
}); | |
/* | |
You need to run mongoose.models.Work.update() here after you've confirmed that there are | |
matching groups. As is this will not actually persist your changes to the database | |
*/ | |
} | |
}); | |
}, function (err) { | |
process.exit(); | |
}); | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment