feroult / yawp

Kotlin/Java API framework for Google Appengine
http://yawp.io
MIT License
132 stars 20 forks source link

Queries with limit does not return any cursor #42

Closed leocabral closed 8 years ago

leocabral commented 8 years ago

If we send a query param with limit (/endpoint/?q={"limit": 3}) it does not return any cursor in the results json... it would be nice to have it :wink:

leocabral commented 8 years ago

@matheusmr13

feroult commented 8 years ago

Today the solution is to work with an Action and the Java API.

Planning to work on this issue soon..

[ ]s

luanpotter commented 8 years ago

Fix 0402b99

Currently the solution is this:

Something like this:

String cursor = "";
for (int i = 0; i < total; i += limit) {
    String json = get("/parents", params("q", "{ limit: " + limit + ", cursor: '" + cursor + "' }"));
    process(asJsonObject(json).get("results")); // process
    cursor = asJsonObject(json).get("cursor").getAsString(); // next cursor
}

If @feroult, @leocabral or @matheusmr13 see a better way to do it without breaking the previous API, please care to comment :)

feroult commented 8 years ago

@luanpotter, I think this is a pretty good solution, not only for back compatibility. :dart: