質問

I'm working with Titanium and developing for iOS and I've come across a small problem, when I want to make a query for custom objects from a certain classname I'm only able to get the last 10 objects, this is how I make the query:

Cloud.Objects.query({
    classname : 'Reservacion'
}, function(e){
   if(e.success){
    reservaciones = e.Reservacion; //assign the custom objects to an array
   }else {
    alert('Error: ' + e.error + e.message);
   }
});

Am I missing something? I know I could specify the number page to retrieve the rest of the objects but the amount of pages will keep growing so I need to find a way to retrieve all of the custom objects for a specific classname. Can anyone give me guidelines on how to solve this?

役に立ちましたか?

解決

I was just looking into this. From the docs if you don't want to use the 'page' and 'per_page' parameters (which default to 1 and 10 respectively).

You need to specify a 'limit' (max is 1000)

If you have over 1000 use the parameter 'skip' on a second query to pick up where you left off.

So your first query might look like this

Cloud.Objects.query({
    classname : 'Reservacion',
    limit : 1000,
}, function(e){
   if(e.success){
    reservaciones = e.Reservacion; //assign the custom objects to an array
   }else {
    alert('Error: ' + e.error + e.message);
   }
});

then a second query (within a loop)

Cloud.Objects.query({
    classname : 'Reservacion',
    limit : 1000,
    skip : 1000   
}, function(e){
   if(e.success){
    reservaciones = e.Reservacion; //assign the custom objects to an array
   }else {
    alert('Error: ' + e.error + e.message);
   }
});

Didn't test, but hope it helps.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top