See the following JavaScript:
(function() {
var allMatches = [];
$.getJSON("myURL", function(data) {
$.grep(data.feed.entry, function(element, index) {
var match = {
day: element.gsx$day.$t,
winner: element.gsx$winner.$t,
field: element.gsx$field.$t,
time: element.gsx$time.$t,
grade: element.gsx$grade.$t,
round: element.gsx$round.$t,
teamOne: element.gsx$team1.$t,
teamOneGoals: element.gsx$goals.$t,
teamOnePoints: element.gsx$points.$t,
teamOneTotal: element.gsx$totalscore.$t,
teamTwo: element.gsx$team2.$t,
teamTwoGoals: element.gsx$goals_2.$t,
teamTwoPoints: element.gsx$points_2.$t,
teamTwoTotal: element.gsx$total.$t
}
allMatches[index] = match;
});
});
var fridayMatches = SQLike.q(
{
Select: ['*'],
From: allMatches,
Where: function(){return this.day === "Friday"},
OrderBy: ['field','|asc|']
}
);
console.log(fridayMatches);
})();
If I put a breakpoint at allMatches[index] = match;
I can clearly see this array being populated fully
However, if I put a breakpoint further down at the start of my SQLike
code allMatches is completely empty.
Why is this, and what is the solution?