Start a new topic

How to use the full aggregation framework in Android

Hi there, how can I perform this query using the Kinvey Android Datastore API?



{ $group: { _id: null, count: { $sum: 1 } } }



Looks like the documentation has some restrictions when talking about aggregation:

I've tried to pass a custom query to some API methods but with no success, I'm guessing if there is a workaround...

GenericJson elems = new GenericJson();

elems.put("_id", null);

elems.put("count", "{ $sum: 1 }");

GenericJson sl = new GenericJson();

sl.put("$group", elems);

Query query = new Query();


It should return something like this:


"result" : [


"_id" : null,

"count" : 5



"ok" : 1


Thanks in advance,

1 Comment

Hi Ruben, Kinvey does not currently support the full Mongo aggregation framework. While supporting the aggregation framework in on our roadmap, currently only the methods listed in the guide linked to in your post are available.
Login or Signup to post a comment