Skip to content

Instantly share code, notes, and snippets.

@artcommacode
Created January 16, 2014 10:14
Show Gist options
  • Save artcommacode/8452596 to your computer and use it in GitHub Desktop.
Save artcommacode/8452596 to your computer and use it in GitHub Desktop.
var whatsOn = [];
Collection.findOne({url: 'whats-on'}).populate('children', null, null, {sort: 'position'}).exec(function (error, collection) {
async.forEachSeries(collection.children, function (child, callback) {
Collection.findAndPopulate({_id: child._id}, function (error, child) {
if (child) whatsOn.push(child);
callback();
});
}, function (error) {
callback(error, whatsOn);
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment