Skip to content

Instantly share code, notes, and snippets.

@jacobgardner
Last active February 8, 2017 05:57
Show Gist options
  • Save jacobgardner/b30b1eeba50128129a6593185c96ef77 to your computer and use it in GitHub Desktop.
Save jacobgardner/b30b1eeba50128129a6593185c96ef77 to your computer and use it in GitHub Desktop.
const Promise = require('bluebird');
const models = Promise.promisifyAll(require('./models'));
const {VehicleModel} = models;
function yourCode() {
Promise.all(vehicles.map((ownedVehicle) => {
return VehicleModel.findOneAsync({_id: ownedVehicle.vehicleId})
.then((vehicle) => {
return {
year: vehicle.year,
make: vehicle.make,
model: vehicle.model,
};
});
})).then((vehicles) => {
// I think this is output in the same order they went in as
res.json(vehicles);
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment