Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cursors and Pagination #121

Open
ghost opened this issue Aug 15, 2014 · 6 comments
Open

Cursors and Pagination #121

ghost opened this issue Aug 15, 2014 · 6 comments
Milestone

Comments

@ghost
Copy link

ghost commented Aug 15, 2014

Is there a way to offset a query, e.g: g.V().GetLimit(limit, offset)? Such a feature would be very handy for pagination purposes.

@barakmich
Copy link
Member

What you really want (and I've been thinking about) is a cursor API. Eg, g.V().Cursor() (returns a cursor token) and then g.Cursor(token).Get(100) (returns 100 things from the prior query and a new cursor token).

This is effectively serialization of iterator trees for those playing at home, and is tangentially related to #64, in that you're building things that may need serialization, but is really just a feature unto itself.

@barakmich barakmich changed the title Query with offset limit Cursors and Pagination Aug 20, 2014
@fisnik
Copy link

fisnik commented Jan 19, 2015

Any news on this feature - i think this is a must, without it, it would be hard to consider Cayley for production on anything dependent on pagination.

Also, how would the cursors be handled? Would the presence of cursors become an impediment on a live production deployment? If you have thousands of clients requesting paginated data, than you would have as many cursors as clients.

@barakmich barakmich mentioned this issue Apr 28, 2015
@jzelinskie
Copy link
Contributor

Totally stealing @barakmich's words:

You can serialize the iterators and encode them and pass them as a token to the client. Thus, the client can just pass the token back and cayley deserializes it and continues iterating for results.

@dennwc dennwc mentioned this issue Jul 9, 2016
@dennwc dennwc modified the milestone: Later. Jul 26, 2016
@iddan
Copy link
Collaborator

iddan commented Jun 30, 2019

I think there should be a streamable content type for Gizmo to allow

@dennwc
Copy link
Member

dennwc commented Jul 28, 2019

@iddan This would require some interactive API like WebSockets or gRPC, but it's easier to implement than serializing the iterator chain (although achievable).

@iddan
Copy link
Collaborator

iddan commented Jul 29, 2019

This would require some interactive API like WebSockets or gRPC

I think writing multiple chunks to the HTTP message will be good enough. In Go's http I think you can use Response.Write() and Response.Flush(). We just need to use a different content type that supports partial messages like NDJSON or NQuads

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants