Callback function never called after Mongoose query is executed

前端 未结 3 763
伪装坚强ぢ
伪装坚强ぢ 2021-02-14 14:25

The following is my code:

mongoose.connect(\'mongodb://localhost/mydatabase\');
  var db = mongoose.connection;
db.on(\'error\', console.error.bind(console, \'co         


        
3条回答
  •  逝去的感伤
    2021-02-14 15:06

    I faced similar issue.

    I was calling process.exit(0) after queries, so the app exited before mongoose have a chance to run callback.

    So i removed process.exit(0) and it worked!

提交回复
热议问题