Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function getAllCity(req, res) {
- var promise = Q.fcall(function() {
- return City.find({}, function(err, cities) {
- if(err) {
- console.log(err);
- return res.send(404)
- }
- for (let i = 0; i < cities.length; i++) {
- Location.findOne({_id : cities[i].locationId}, function(err, location){
- if(err) return;
- cities[i].locationLng = location.lng;
- cities[i].locationLat = location.lat;
- });
- }
- });
- });
- promise.then(function(data) {
- console.log(data);
- }, function(err) {
- console.log(err);
- });
- // return res.json({isSucess: true, data: cities})
- };
Add Comment
Please, Sign In to add comment