Tutorial :datastore.Cursor - paging in reverse supported?



Question:

I'm looking at the documentation for using cursors. Are these forward-only cursors - we can't page backwards?:

http://code.google.com/appengine/docs/java/datastore/queriesandindexes.html#Query_Cursors

Cursor cursor = Cursor.fromWebSafeString(cursorString);  Map<String, Object> extensionMap = new HashMap<String, Object>();  extensionMap.put(JDOCursorHelper.CURSOR_EXTENSION, cursor);  query.setExtensions(extensionMap);  query.setRange(0, 20);  

could we set the range to (-20, 0) ?

I imagine the user would want to be able to go to the previous page of elements as well as forward.


Solution:1

No, there is no way to go backwards with cursors with the current release.

You could "fake" it, however, by caching previous cursors.

Note: According to Alfred Fuller's Google IO talk, at some point in the future app engine will hopefully support reverse cursors too.


Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »