So i got this
for(var i =0;i<result.length;i++){
User.find(result[i].user).then((err,user)=>{
resultArray.push({name : result[i].name, userName : user.name});
}
}
but it doesn't work because the loops end before the promises resolves. So i wanted to know if i could give a copy of i to the User.find() callback? I don't know any way to keep the data synced between the result and user array, since i don't know in which order the promises are gonna be resolved.