如果函數返回1K文件我不得不重複1K倍。
如何添加爲每個文檔執行的回調?喜歡的東西:
var each = function (e){
return convert (e);
};
Emotion.find (query, "-_id", opts, each, function (error, e){
if (error) return cb (error, 500);
cb (null, e);
});
基本上,我需要每一個()的MongoDB的使用:http://mongodb.github.com/node-mongodb-native/api-generated/cursor.html#each
編輯:也許這是可以做到聽從流數據的事件,推動該文件到一個數組:
http://mongoosejs.com/docs/api.html#query_Query-stream
這是你所需要的? – shelman 2013-03-25 15:34:51
是的,但我注意到這比使用mongodb中的每個()慢得多 – 2013-03-25 15:41:53
在這種情況下,您可以從Mongoose中下載到本地驅動程序中,如[this]中所述(http:// stackoverflow.com/questions/10519432/how-to-do-raw-mongodb-operations-in-mongoose)問題。 – shelman 2013-03-25 15:46:58