Skip to content

Commit

Permalink
Replace .push with .concat to port to Mongodb 4
Browse files Browse the repository at this point in the history
  • Loading branch information
cirosantilli committed Mar 22, 2021
1 parent ba04b70 commit 8d606e7
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions models/User.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = this.favorites.concat([id]);
}

return this.save();
Expand All @@ -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 = this.following.concat([id]);
}

return this.save();
Expand Down
2 changes: 1 addition & 1 deletion routes/api/articles.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = req.article.comments.concat([comment]);

return req.article.save().then(function(article) {
res.json({comment: comment.toJSONFor(user)});
Expand Down

0 comments on commit 8d606e7

Please sign in to comment.