3
我已经定义了这个路由,但是对它的任何请求都被卡在'pending'并且永远运行。Mongoose .find()方法导致请求挂起
当我登录的代码,我看到1
其次是4
,这意味着find方法中的代码永远不会被执行
# Calendar routes
router.get '/calendars', (req, res) ->
console.log '1'
Calendar.find (err, calendars) ->
console.log "2" + err
console.log "3" + calendars
res.send(err) if err
res.json(calendars)
return
console.log '4'
return
型号
mongoose = require("mongoose")
module.exports = mongoose.model("Calendar",
name: String
)
为什么这是任何想法?
当Mongoose回调未被调用时,通常是因为该模型的连接未打开。你的'mongoose.connect'调用是否成功? – JohnnyHK 2014-12-06 14:42:58
我该如何检查? – Tarlen 2014-12-06 15:24:57
为你的'mongoose.connect'调用提供一个回调函数参数。 – JohnnyHK 2014-12-06 16:00:08