Created
April 12, 2012 17:23
-
-
Save adampax/2369326 to your computer and use it in GitHub Desktop.
paging through large query result sets with Titanium and ACS
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
//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