2014-06-22 89 views
0
> cpu.findOne({}).sort({_id: -1}).limit(1).exec(function (err, huh) { 
... if (err) return handleError(err); 
... console.log(huh.status); 
... console.log("hi"); 
... }) 

{ domain: null, 
    _events: { err: [Function], complete: [Function] }, 
    _maxListeners: 10, 
    emitted: {}, 
    ended: false } 

如何獲取發現以字符串格式打印到控制檯的文檔?我只是得到這個對象。MongoDb Mongoose .exec()無法獲得結果到控制檯

編輯:

> cpu.findOne({}).sort({_id: -1}).limit(1).exec(function (err, result) { console.log(err) }) 
{ domain: null, 
    _events: { err: [Function], complete: [Function] }, 
    _maxListeners: 10, 
    emitted: {}, 
    ended: false } 
> 
+1

'handleError'做了什麼?您是否驗證過錯誤路徑未被調用? – dylants

+0

我現在不在乎'handleError',我從貓鼬的文檔示例中得到了這個。我只是想讓記錄返回到控制檯。它在那裏...貓鼬記錄對象。 – dman

+2

如果不知道「huh」對象中的「status」是什麼,很難回答。另外,上面粘貼的輸出不會打印「hi」,因此尚不清楚在該點之前是否存在導致日誌記錄停止的錯誤。 – dylants

回答

0

正如上面dylants所指出的,貓鼬不能正確地打印到控制檯從節點殼跑時。