auroraresearchlab / netbox-dns

Netbox Dns is a netbox plugin for managing zone, nameserver and record inventory.
MIT License
208 stars 19 forks source link

Filter by id #294

Open joernheissler opened 1 year ago

joernheissler commented 1 year ago

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

peteeckel commented 1 year ago

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 commented 1 year ago

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 commented 1 year ago

Ah, that makes sense - thanks!