I'm using cloud code to get multiple counts in a single call (see below):
Parse.Cloud.define("BeerCount", function(request, response){
var yellowCount = new Parse.Query("beer_rating").equalTo("beer_colour", "Yellow").equalTo("userId", request.params.userid).count();
var tanCount = new Parse.Query("beer_rating").equalTo("beer_colour", "Tan").equalTo("userId", request.params.userid).count();
var brownCount = new Parse.Query("beer_rating").equalTo("beer_colour", "Brown").equalTo("userId", request.params.userid).count();
var blackCount = new Parse.Query("beer_rating").equalTo("beer_colour", "Black").equalTo("userId", request.params.userid).count();
var redCount = new Parse.Query("beer_rating").equalTo("beer_colour", "Red").equalTo("userId", request.params.userid).count();
var orangeCount = new Parse.Query("beer_rating").equalTo("beer_colour", "Orange").equalTo("userId", request.params.userid).count();
Parse.Promise.when(yellowCount, tanCount, brownCount, blackCount, redCount, orangeCount)
.then(function(countOfYellow, countOfTan, countOfBrown, countOfBlack, countOfRed, countOfOrange){
response.success({
yellowCount: countOfYellow,
tanCount: countOfTan,
brownCount: countOfBrown,
blackCount: countOfBlack,
redCount: countOfRed,
orangeCount: countOfOrange
});
});
});
Although this is quite quick on a fast wi fi connection, it would be almost impossible to carry out this when not connected to fast conneciton. I am wondering is it possible to cache this? I am using a cache policy of cache_then_network on all my android based queries and I hoped to do the same with this...if anyone knows this I'd appreciate it if you could let me know...