有没有办法从 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
});
});
});
可能有更好的方法来做到这一点,所以我也愿意这样做。谢谢。
最佳答案
不是,但是 map-reduce 函数接受查询,因此您不需要查找 :)
http://mongodb.github.com/node-mongodb-native/api-generated/collection.html#mapreduce
关于javascript - 如何使用 node-mongodb-native 在 mongodb find() 的回调中返回一个临时集合?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10602007/