如果函数返回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