Skip to content

Instantly share code, notes, and snippets.

@ermst4r
Created September 6, 2016 08:08
Show Gist options
  • Save ermst4r/efb43793709f99f2dc8a687fb5651b71 to your computer and use it in GitHub Desktop.
Save ermst4r/efb43793709f99f2dc8a687fb5651b71 to your computer and use it in GitHub Desktop.
module.exports = {
run:function()
{
Feed.find({}).then(function(feed) {
var page = 1,
lastPage = feed.length;
async.whilst(function () {
return page <= lastPage;
},
function (next) {
console.log(feed[page]); // Get value by incrementor because it is an async array
/**
* Or just do an insert into mongo
* mongo.insert(feed); should be a json array
*/
/** INSERT HERE INTO MONGO **/
page++;
next();
});
},
function (err) {
// All things are done!
console.log("Done isnerting");
});
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment