0
我正在用貓鼬弄髒aroung,我只是試圖返回一個在我的集合(這對我的理解是相當於一個SQL表中的行)的對象。貓鼬查詢不會返回錯誤
在視頻中,我正在看它說從貓鼬返回錯誤和結果的所有回調,但我只能返回結果從來沒有錯誤(日誌爲未定義),即使當我強迫一個錯誤沒有任何反應。
我該如何找出何時出現錯誤?
這裏是我的代碼。
app = require("../server")
dashboard = require("../models/dashboard")
app.get('/request', (req, res)->
dashboard.users.find({}).exec().then (users, err) ->
console.log err
res.send users
)
第二個參數總是出來undefined,不管我命名它。另外這是寫在CoffeeScript中我會低於
var app, dashboard;
app = require("../server");
dashboard = require("../models/dashboard");
app.get('/request', function(req, res) {
return dashboard.users.find({}).exec().then(function(users, err) {
console.log(err);
return res.send(users);
});
});
即使當我反轉它的第二個參數是不確定的,不管我做什麼,如果第一個參數是錯誤,爲什麼它返回我的結果呢? – grasshopper 2014-10-09 14:06:27
@grasshopper如果第二個參數總是未定義,那麼「爲什麼它返回我的結果」是什麼意思?這些言論似乎相互矛盾。 – robertklep 2014-10-09 14:09:09
它返回查詢結果,因此,而不是得到一個錯誤消息,我得到我的集合中的一切 – grasshopper 2014-10-09 22:33:52