Optimize rest api fetching of data from mongo