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

Pagination support for Model.nodes.all() and Model.nodes.filter() #852

Open
juanmontenegro58 opened this issue Jan 13, 2025 · 2 comments
Open

Comments

@juanmontenegro58
Copy link

Feature description

I would like to know if it's possible to implement pagination directly with the following queries using Neomodel: Model.nodes.all(). I have reviewed the official documentation, but I couldn't find any information on how to add pagination (e.g., using SKIP and LIMIT in Cypher) directly to these queries. My question is whether there's an efficient way to apply pagination to these queries without needing to write Cypher queries manually.

Considered alternatives

I considered manually writing Cypher queries using SKIP and LIMIT, but I would prefer to use the standard Neomodel query (Model.nodes.all() and Model.nodes.filter(relation__relation__attr_node=value)) without having to handle pagination manually.

I would greatly appreciate any information or guidance regarding this feature. Thank you in advance for your time and support!

@mariusconjeaud
Copy link
Collaborator

mariusconjeaud commented Jan 14, 2025

Hello, native Python slicing works and creates queries with SKIP and LIMIT. See here in the docs

Basically : Coffee.nodes.filter(price__gt=2)[2:12] will skip 2 limit 10

@juanmontenegro58
Copy link
Author

Hello, thank you for your prompt response.

I tested the solution you suggested, and at first, I thought that using slicing would load all the data into memory. However, after enabling the logs and analyzing the generated queries, I confirmed that they do include the SKIP and LIMIT commands, as you mentioned.

I really appreciate your explanation and the time you took to clarify my concern. Thanks again!

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

No branches or pull requests

2 participants