Last active
February 8, 2017 05:57
-
-
Save jacobgardner/b30b1eeba50128129a6593185c96ef77 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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