Having set up a datastore, how does one loop through, accessing all the elements e.g. given

Code:
for(var i=0;i<ds.getTotalCount();i++){
....

}