Right now, this isn't doable using the paginate
method. WillPaginate returns WillPaginate::Collection
objects that are already populated from the database. We might be able to make it return something else and evaluate lazily but I'd have to play around with it more.
You can create Neo4j::Paginated
objects directly, but these are just plucked results from QP.
# match stupid friends with awful events, return distinct events
query = current_user.friends(:f).where(stupid: true).events(e:).rel_where(expected_attendees: 0)
@bad_events = Neo4j::Paginated.create_from(query, 1, 15).pluck('distinct e')
create_from
returns a Neo4j::Paginated
object that delegates each
and pluck
to its the QueryProxy object fed to it. Note that it's going to paginate based on the end of the chain, so it's doing the first page with 15 per page based on the events. Also note that you can't do a distinct count.
Check https://github.com/neo4jrb/neo4j/blob/master/lib/neo4j/paginated.rb for more. It's pretty easy to read.