I have a collection called 'alldetails' which have the details of some collection
{
    "name" : "Test1",
    "table_name" : "collection1",
    "column_name" : "column1"
},
{
    "name" : "Test2",
    "table_name" : "collection2",
    "column_name" : "column2"
},
{
    "name" : "Test3",
    "table_name" : "collection3",
    "column_name" : "column3"
}
I have collection1,collection2 and collection3 which have column1,column2,colum3 respectively
I have to fetch all the name from the 'alldetails' and I have to get the min and max value of other table based on the column name.
So I want the output like below
{name: ["Test1","Test2","Test3"],
date: [{min_date: "2018-12-01", max_date: "2018-12-31", name: "Test1"},
              {min_date: "2018-12-01", max_date: "2018-12-31", name: "Test2"},
              {min_date: "2018-12-01", max_date: "2018-12-31", name: "Test3"}]
}
I tried the below code because of non blocking its not waiting the response.
alldetails.find({}, { _id: 0 }).then(async function(result) { 
    let result_data = {};  
    let resolvedFinalArray = {};
    let array = [];
    result_data["name"]= [];
    result_data["date"] = [];
    resolvedFinalArray = await Promise.all(result.map(async value => { 
      result_data["name"].push(value.name)  
      getResult(value.table_name,value.column_name,function(response){
           result_data["date"].push({min_date: response.minvalue, max_date: response.maxvalue, name:value.name})          
       });     
    }));
    setTimeout(function()
    { 
      console.log(resolvedFinalArray);
    }, 3000);
});
Please suggest me a solution.
 
     
     
     
     
    