Last active
July 8, 2017 00:17
-
-
Save steniowagner/3ff5da0937e541c063092c5645f95d04 to your computer and use it in GitHub Desktop.
model
This file contains 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
UserController.prototype.getUserFeed = function(request, response, next) { | |
var _id = request.params._id; | |
var context = this; | |
this.model.findOneAsync(_id) | |
.then(handleNotFound) | |
.then(function(user) { | |
return user; | |
}) | |
.then(function(user) { | |
context.model.findAsync({_id: {$in: user.following}}) | |
.then(function(followingUser) { | |
var userFeed = []; | |
var followingUsersPics = function(followingUser) { | |
userFeed = _.concat(userFeed, followingUser.pics) | |
}; | |
followingUser.map(followingUsersPics); | |
response.status(200); | |
response.json({feed: userFeed}) | |
}) | |
.catch(next); | |
}) | |
.catch(next); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment