Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/solr/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Node.js mongodb中大数据集的划分_Node.js_Mongodb_Csv - Fatal编程技术网

Node.js mongodb中大数据集的划分

Node.js mongodb中大数据集的划分,node.js,mongodb,csv,Node.js,Mongodb,Csv,我需要将mongodb的大型数据集转换为CSV。为此,我决定使用async.queue和并发级别=no of core。示例代码如下所示 var q = async.queue(function (task, cb) { collection.find(query).skip(task.skip).limit(task.limit) .toArray(function (err, docs) { // convert that data to CSV and pu

我需要将mongodb的大型数据集转换为CSV。为此,我决定使用
async.queue
并发级别=no of core。示例代码如下所示

var q = async.queue(function (task, cb) {
collection.find(query).skip(task.skip).limit(task.limit)
    .toArray(function (err, docs) {
            // convert that data to CSV and push them in a Array
    })
}, cores);

var offset = 0;
var limit = count / cores;
for (; cores >= 0; cores--) {
    q.push({skip: offset, limit: limit});
    offset += limit
}
// return the result after everything is done
q.drain = function () {
    callback(inMemoryCsv.join())
};
但是mongo docs表示,在
mongodb
中,跳过非常昂贵。那么,在这种情况下,我能做些什么

它是一个Rest端点,用户在此请求下载CSV。基本上都是实时的


我这样做对吗。。。?有其他方法吗?

对于疼痛csv导出,我会使用。如果您有特定要求,请通过编辑将其添加到问题中。@MarkusWMahlberg更新了问题。它是一个rest端点。我的意思是实时下载用于导出,我会使用。如果您有特定要求,请通过编辑将其添加到问题中。@MarkusWMahlberg更新了问题。它是一个rest端点。我是说实时下载