Alternatives to MongoDB cursor.toArray() in node.js
I am currently using MongoDB cursor's toArray() function to convert the database results into an array: run = true; count = 0; var start = process.hrtime(); db.collection.find({}, {limit: 2000}).toArray(function(err, docs){ var diff = process.hrtime(start); run = false; socket.emit('result', { result: docs, time: diff[0] * 1000 + diff[1] / 1000000, ticks: count }); if(err) console.log(err); }); This operation takes about 7ms on my computer. If I remove the .toArray() function then the operation takes about 0.15ms. Of course this won't work because I need to forward the data, but I'm wondering