I want to order a request based on several values. The problem is that I cannot select the type object key, because I get undefined when I do this.
var filterDataAccordingToDate = function(ref, startTime, endTime, travelType) { ref.orderByChild('date') .startAt(startTime).endAt(endTime) .once('value', function(snapshot) { var travel = snapshot.val(); console.log("TRAVEL OBJ: " + util.inspect(travel, false, null)); console.log("TRAVEL TYPE: " + travel.type); if (travel.type == travelType) {
The first console.log() returns the correct object:
TRAVEL OBJ: { "-KKiZKAVH0-QulKnThhF" : { "date" : 1466439009, "dest" : 1, "fbKey" : "-KKiZKAVH0-QulKnThhF", "type" : 1 } }
Second: TRAVEL TYPE: undefined
Any idea where I made a mistake?
source share