I am new at Javascript and I have a problem when I want to get list of model by its ID. I have read about "promise" but I do not know the right way to use it in this case. This is my code
var ids = [1, 2, 3];
var cars = [];
ids.forEach(function (id, index, array) {
Car.findOne({_id: id}, function(err, car){
cars.push(car);
});
});
return cars;
Help me please. Thank you all!