Page 1 of 1

How to fetch a random record?

Posted: Sun Oct 21, 2012 5:48 pm
by Social

I'm trying to pull back just one of the 7 records from my 'messages' collection in the Tiggzi cloud DB.

I've tried putting /random on the end of the service :

https://api.tiggzi.com/rest/1/db/coll...

(not sure if that is correct but doesn't work anyway)

and I've tried running a custom javascript onPageShow:

Code: Select all

function getRandomInt (min, max) {  
    var myVar = [1,2,3,4,5,6,7].randomItem(); 
} 

but in datamapping my variable doesn't show up so I can map it to the text input.

Can anyone put me on the right track please?

thanks in advance
Mike


How to fetch a random record?

Posted: Sun Oct 21, 2012 8:53 pm
by maxkatz

Here is one option. Save the id's of all the records and then randomly pick an id, then do a GET request with it.