Let's take a look at the first use of async in one of our helpers, the comments helper. Originally, helpers/comments.js was a module that had a newest function that returned an array of fixture data with some sample comments. We are going to completely remove this code and instead query MongoDB for the newest comments and return those as an array. Start by clearing the comment helper module and starting from scratch (note that we included a new callback parameter to the newest function):
var models = require('../models'), async = require('async'); module.exports = { newest: (callback)=>{ // to do... } };
Notice that we added the additional require statements at the top of the file for our models and async. Within the ...