Skip to content

Instantly share code, notes, and snippets.

@adampax
Created April 12, 2012 17:23
Show Gist options
  • Save adampax/2369326 to your computer and use it in GitHub Desktop.
Save adampax/2369326 to your computer and use it in GitHub Desktop.
paging through large query result sets with Titanium and ACS
//paging through large query result sets with Titanium and ACS
//http://adampaxton.com
function doQuery(n){
Cloud.Objects.query({
classname: 'cars',
per_page: 100,
page: n || 1
}, function (e) {
if (e.success) {
Ti.API.info('Result set length : ' + e.cars.length);
for (var i = 0; i < e.cars.length; i++) {
var car = e.cars[i];
Ti.API.info('id: ' + cars.id + '\\n' +
'make: ' + car.make + '\\n' +
'color: ' + car.color + '\\n' +
'year: ' + car.year + '\\n' +
'created_at: ' + car.created_at);
}
if(n < e.meta.total_pages){
doQuery(++page);
}
} else {
alert('Error:\\n' +
((e.error && e.message) || JSON.stringify(e)));
}
});
}
var page = 1;
doQuery(page);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment