1

有没有办法从 find() 操作而不是游标返回临时集合?我正在使用 node-mongodb-native 驱动程序,我想对 find() 操作的结果运行 mapReduce。像这样的东西:

client.open(function(err) {
    client.collection(collectionName, function(err, collection) {
        collection.find( {days_since_epoch: {$gte: query.begin}).toArray(function(err, docs) {
            // Need to run a mapReduce here on the results
            // Preferably on a temporary collection instead of the default cursor or array above
       });
    });
});

可能有更好的方法来做到这一点,所以我也愿意。谢谢。

4

1 回答 1

4

不,但是 map-reduce 函数需要一个查询,所以你不需要 find :)

http://mongodb.github.com/node-mongodb-native/api-generated/collection.html#mapreduce

于 2012-05-15T16:52:58.810 回答