Skip to content

Instantly share code, notes, and snippets.

@steniowagner
Last active July 8, 2017 00:17
Show Gist options
  • Save steniowagner/3ff5da0937e541c063092c5645f95d04 to your computer and use it in GitHub Desktop.
Save steniowagner/3ff5da0937e541c063092c5645f95d04 to your computer and use it in GitHub Desktop.
model
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