Using promise function inside Javascript Array map
You are not returning your Promises inside the map
function.
[obj1, obj2].map(function(obj){
return db.query('obj1.id').then(function(results){
obj1.rows = results
return obj1
})
})
Map your array to promises and then you can use Promise.all() function:
var promises = [obj1, obj2].map(function(obj){
return db.query('obj1.id').then(function(results){
obj1.rows = results
return obj1
})
})
Promise.all(promises).then(function(results) {
console.log(results)
})