Question: In the absence of Parse.Query.random() I'd ideally like to do:

```
query.count.then(function(theCount){
    return query.skip(randomNumber%theCount).first();
}).then(function(aRandomObjectConformingToQuery){
   // Do stuff to the random object.
});

```

But count operations are discouraged and for large queries won't complete.

Is there any way to get a random object from a subset of a table. e.g. "Get me one of my users who's name is Roger so I can award him a prize" because of the prize, first() doesn't work for me.

Answer: 
So there is no `query.random()` although Parse have added this to their backlog.

In the meantime, there are two ways to get a random object:

1. Maintain a count of your objects and set `query.skip` to be a random number [0,count]
2. Run a query to retrieve all your objects (this may not be possible) and then select a random one from the array.

2 is less error prone because maintaining a count of objects in Parse is unreliable but it isn't truly random. In my case it works though.
This is working code for fetching random objects from given class in Parse

In cloud code,

```
Parse.Cloud.define("get10Obj",function(request,response)
{ 

query = new Parse.Query(request.params.movie);

Array.prototype.randomElement = function (min, max) {
return Math.floor(Math.random() * (max - min + 1)) + min;
}

query.find ({

success: function(results) {

        var final10 = [];

        for (var i = 0; i < 5; i++) {
            var myRandomElement = results.randomElement(0,results.length);

            if (final10.indexOf(myRandomElement) == -1) {
                final10.push(myRandomElement);
            } else {
                i--;
            }
        }
         var datalist =[];

        for(var j=0;j<final10.length;j++)
        {
            var index= final10[j];
            datalist.push(results[index]);
        }   

        response.success(datalist);
    },
    error: function() {
        response.error(error);
      }
    });
  });

```

In Android,

```
    HashMap<String, Object> params = new HashMap<String, Object>();
    params.put("movie", "The Matrix");

    ParseCloud.callFunctionInBackground("averageStars", params, new
       FunctionCallback<ParseObject>() {
      void done(ParseObject ratings, ParseException e) {
       if (e == null) {
          // Do your stuff
          }
      }
   });

```