阅读背景:

Mongoose不会将数据保存到MongoDB

来源:互联网 


Below is an object literal I am trying to save to MongoDB. It is defined within the app.js file which is an Express server. As the object is hardcoded within the server, my assumption was that a new copy would be saved to the DB every time I run the server, or at the very least the document would be saved once, and overridden or left unchanged upon detection that the new document is identical to the one saved on the last server run. To my astonishment, not only no copies are created within the MongoDB, but the document is not saved at all. However, the 'news' collection has been created, as verified with mongo shell 'show collections'. Also, I am not getting any error in the callback function. I also tried the Model.create(doc, fn) within my Express '/news' route, but this also doesn't work (the doc should be saved every time the '/news' route is called by the client, but it isn't). What am I missing? Below is an object literal I am trying to save




你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: