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?



db.products.aggregate(

[

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

]

)



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

http://devcenter.kinvey.com/android/guides/datastore#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();

query.equals(sl);





It should return something like this:



{

"result" : [

{

"_id" : null,

"count" : 5

}

],

"ok" : 1

}



Thanks in advance,

Ruben.
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