Skip to content

Commit 73c793d

Browse files
committed
Replace .push with .concat to port to Mongodb 4
Otherwise actions such as commenting fail with: Unknown modifier: $pushAll As per: https://stackoverflow.com/questions/48607918/mongoerror-unknown-modifier-pushall-in-node-js/50435618#50435618 Tested on Ubuntu 20.10, Mongo 4.4.4, https://github.com/gothinkster/vue-realworld-example-app at 61742206c170db02b04d63c7e9d43807d8c6b902 with only the URL modified: diff --git a/src/common/config.js b/src/common/config.js index 03af84e..ccd9c4d 100644 --- a/src/common/config.js +++ b/src/common/config.js @@ -1,2 +1,2 @@ -export const API_URL = "https://conduit.productionready.io/api"; +export const API_URL = "http://localhost:3000/api"; export default API_URL; Fix #57 Fix #96 Fix #64
1 parent ba04b70 commit 73c793d

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

models/User.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ UserSchema.methods.toProfileJSONFor = function(user){
6060

6161
UserSchema.methods.favorite = function(id){
6262
if(this.favorites.indexOf(id) === -1){
63-
this.favorites.push(id);
63+
this.favorites = this.favorites.concat([id]);
6464
}
6565

6666
return this.save();
@@ -79,7 +79,7 @@ UserSchema.methods.isFavorite = function(id){
7979

8080
UserSchema.methods.follow = function(id){
8181
if(this.following.indexOf(id) === -1){
82-
this.following.push(id);
82+
this.following = this.following.concat([id]);
8383
}
8484

8585
return this.save();

routes/api/articles.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ router.post('/:article/comments', auth.required, function(req, res, next) {
254254
comment.author = user;
255255

256256
return comment.save().then(function(){
257-
req.article.comments.push(comment);
257+
req.article.comments = req.article.comments.concat([comment]);
258258

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

0 commit comments

Comments
 (0)