Created
May 31, 2013 03:57
-
-
Save alyraz/5682870 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
res.on('end', function(){ | |
var parser = require('xml2json'); | |
var allCampgrounds = parser.toJson(data, {object: true}); | |
var availableCampgrounds = _.where(allCampgrounds.resultset.result, { availabilityStatus: "Y", contractID: 'CA' }); | |
var queryCount = availableCampgrounds.length; | |
console.log(queryCount) | |
_.each(availableCampgrounds, function(campground){ | |
var getPhotoSrc = client.query("SELECT src_url FROM campground_photos WHERE campground_facility_id = ($1)", [ campground.facilityID ], | |
function(err, rows, fields){ | |
if(err) throw err; | |
console.log(rows) | |
queryCount--; | |
console.log(queryCount); | |
if(queryCount === 0 ) { | |
pageRes.render('campgroundResults', { | |
title: '~CaliCamping~', | |
startDate: startDate, | |
endDate: endDate, | |
numNights: numNights, | |
data: availableCampgrounds | |
}); | |
} | |
}); | |
}); // each | |
}) // res.on('end') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment