I am fetching all data from collection and that operation is taking time. And there are chances that data may increase in near future. So I need to optimize the query. But I have no filter parameters, I want all data as it is.
collection().find.toArray(function(err, data){
if(err){
console.log("unable to fetch data from collection",err);
res.status(400).json({error : 'Unable to fetch data'});
}
else{
console.log("data send",data.length);
res.status(200).send(data);
}
})
How can I optimize this, so that It will not take much time.
Thanks Mangesh