diff --git a/models/User.js b/models/User.js index cb6c0f2b0..d584b90d7 100644 --- a/models/User.js +++ b/models/User.js @@ -60,7 +60,7 @@ UserSchema.methods.toProfileJSONFor = function(user){ UserSchema.methods.favorite = function(id){ if(this.favorites.indexOf(id) === -1){ - this.favorites.push(id); + this.favorites.unshift(id); } return this.save(); @@ -79,7 +79,7 @@ UserSchema.methods.isFavorite = function(id){ UserSchema.methods.follow = function(id){ if(this.following.indexOf(id) === -1){ - this.following.push(id); + this.following.unshift(id); } return this.save(); diff --git a/routes/api/articles.js b/routes/api/articles.js index e0f1074ba..8a7da5a96 100644 --- a/routes/api/articles.js +++ b/routes/api/articles.js @@ -254,7 +254,7 @@ router.post('/:article/comments', auth.required, function(req, res, next) { comment.author = user; return comment.save().then(function(){ - req.article.comments.push(comment); + req.article.comments.unshift(comment); return req.article.save().then(function(article) { res.json({comment: comment.toJSONFor(user)});