Last active
December 20, 2015 00:29
-
-
Save turbo1912/6042558 to your computer and use it in GitHub Desktop.
updating the post type before sending the post to the view..
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
User.findOne({ twitterID: req.user.id }, | |
function(err, user) { | |
if (user){ | |
var votedPosts = user.votedPosts; | |
Post.find(function (err, posts) { | |
if(posts){ | |
for (var i = 0; i < posts.length; i++){ | |
for (var j = 0; j < votedPosts.length; j++){ | |
if(String(votedPosts[j]._id) == String(posts[i]._id)){ | |
posts[i].votetype = votedPosts[j].votetype; | |
} | |
} | |
if (!posts[i].votetype){ | |
posts[i].votetype = 0; | |
} | |
} | |
res.send(posts); | |
} | |
}); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment