Mongoose instance .save() not working

前端 未结 7 721
情歌与酒
情歌与酒 2020-12-30 00:43

I have a problem with Mongoose and MongoDb

It is very interesting that only Model.update works and save never works and does not even fire

7条回答
  •  暖寄归人
    2020-12-30 01:23

    This sounds nuts.. and I've been trying to work through this problem for hours. Looked at so many stack overflow posts.. it's unbelievable.

    And you know what it was? I wasn't specifying the database at the end of the url.

    So instead of

    "mongodb://127.0.0.1:27017/test"
    

    I had

    "mongodb://127.0.0.1:27017
    

    I wasted a whole day on this. I really wish I was given errors of some kind. Saving a record always returned ok. And in the database log, I was connecting ok. But I really needed to look at the details. Yes, it was connecting to the mongo instance, but not to the database itself. ugh!

提交回复
热议问题