Skip to content
This repository has been archived by the owner on May 24, 2024. It is now read-only.

Filter by id #294

Open
joernheissler opened this issue Apr 29, 2023 · 3 comments · May be fixed by #295
Open

Filter by id #294

joernheissler opened this issue Apr 29, 2023 · 3 comments · May be fixed by #295

Comments

@joernheissler
Copy link

joernheissler commented Apr 29, 2023

Hello,
I'd like to filter netbox-dns objects by ID, e.g.
GET /api/plugins/netbox-dns/records/?id=12 or GET /api/plugins/netbox-dns/records/?id__gt=38&ordering=id&limit=25

@joernheissler joernheissler linked a pull request Apr 29, 2023 that will close this issue
@peteeckel
Copy link
Contributor

Hi @joernheissler, just out of curiosity: What's the use case for this? Wouldn't it make more sense to be able to filter for, e.g., creation time (assuming the NetBox API allows it, which I assume)?

@joernheissler
Copy link
Author

My actual use case is dumping complete tables while using pagination. My real query is:
?id__gt=0&ordering=id&limit=25 on first request and e.g. ?id__gt=28&ordering=id&limit=25 on next, assuming the largest id I received during first query was 28.

When paginating like this, there will never be duplicates (record added betweeen two requests), missing rows (record removed between two requests) and it won't require a full table scan like LIMIT 15000,25 would, as there's already an index on the id column.

@peteeckel
Copy link
Contributor

Ah, that makes sense - thanks!

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

Successfully merging a pull request may close this issue.

2 participants