Last active
August 29, 2015 14:02
-
-
Save kedarmhaswade/97d04e5a693de824b13f to your computer and use it in GitHub Desktop.
debug all
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
| all: function(params, callback) { | |
| var async = require('async'); | |
| var reviews = null; | |
| async.series([ | |
| function load_reviews(cb) { | |
| Reviews.find().exec(function (err, result) { | |
| reviews = result; | |
| cb(null, reviews); | |
| }); | |
| }, | |
| function load_user(cb) { | |
| reviews.forEach(function (review) { | |
| Users.findOne().where({id:review.userId}).exec(function (err, result) { | |
| review.user = result[0]; | |
| }); | |
| }); | |
| cb(null, reviews); | |
| }, | |
| function load_comments(cb) { | |
| reviews.forEach(function (review) { | |
| Comments.find().where({reviewId: review.id}).where({ modComment: false}).exec(function (err, result) { | |
| review.comments = result; | |
| }); | |
| Comments.find().where({reviewId: review.id}).where({ modComment: true}).exec(function (err, result) { | |
| review.comments = result; | |
| }); | |
| cb(null, reviews); | |
| }); | |
| } | |
| ], function(err, results) { | |
| callback(err, results); | |
| }); | |
| }, |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment