piccolo-orm / piccolo_api

ASGI middleware for authentication, rate limiting, and building REST endpoints.
https://piccolo-api.readthedocs.io/en/latest/
MIT License
146 stars 27 forks source link

Be able to filter bulk DELETE and GET queries by a list of row IDs #11

Open dantownsend opened 3 years ago

dantownsend commented 3 years ago

Currently, PiccoloCRUD (and hence FastAPIWrapper) allow you to filter by the row ID, but you can't filter by a list of IDs.

For example:

# Currently supported:
DELETE /api/tables/movies?id=1

# Proposed:
DELETE /api/tables/movies?id=1,2,3,4,5

This would be a very useful feature, and would make bulk deletes more efficient.

sinisaos commented 3 years ago

@dantownsend We can do this similarly to visible_fields. My question is whether we can replace the delete_all method (which is disabled by default with allow_bulk_delete is False) with delete_bulk method or delete_bulk method must be separated, with a separate endpoint? If we can replace delete_all (I already wrote working code) we can set allow_bulk_delete to True because there is no longer a chance for user to delete all records, but only the results whose id is in the query params. For example:

DELETE /api/tables/movies/?__ids=1,2,3,4,5  (only rows with id is in __ids will be deleted)
sinisaos commented 3 years ago

@dantownsend What do you think of this idea?